Ogwiritsa ntchito ena akufuna kupanga intaneti patokha pakati pa makompyuta awiri. Ntchitoyi imatheka pogwiritsa ntchito ukadaulo wa VPN (Virtual Private Network). Kulumikizanaku kumayendetsedwa kudzera zofunikira komanso zotsekedwa ndi mapulogalamu. Pambuyo kukhazikitsa bwino ndikusintha kwa zigawo zonse, njirayi imatha kuganiziridwa kuti yatha, ndipo kulumikizidwa ndikutetezedwa. Chotsatira, tikufuna kukambirana mwatsatanetsatane kukhazikitsa ukadaulo kudzera pa kasitomala wa OpenVPN mu kachitidwe kogwiritsa ntchito Linux kernel.
Ikani OpenVPN pa Linux
Popeza ogwiritsa ntchito ambiri amagwiritsa ntchito kugawa potengera Ubuntu, lero malangizowa azikhala pamtunduwu. Nthawi zina, simudzazindikira kusiyana pakukhazikitsa ndi kukhazikitsa kwa OpenVPN, pokhapokha mutatsatira kutsatira kapangidwe kanu, kamene mungawerenge pazosankha zanu. Tikukulimbikitsani kuti muzidziwitsa momwe gawo lililonse limathandizira kuti mumvetsetse mwatsatanetsatane zomwe zikuchitika.
Onetsetsani kuti mukuwona kuti kugwira ntchito kwa OpenVPN kumachitika kudzera m'malo awiri (pakompyuta kapena pa seva), zomwe zikutanthauza kuti kuyika ndi kukhazikitsa kumakhudza onse omwe akutenga nawo mgwirizano. Buku lathu lotsatira likulunjika makamaka pakugwira ntchito ndi magwero awiri.
Gawo 1: Ikani OpenVPN
Zachidziwikire, muyenera kuyamba kuwonjezera makalata onse omwe amafunikira makompyuta. Konzekerani kuti OS yomwe ili mokhazikika idzagwiritsidwa ntchito kumaliza ntchitoyo. "Pokwelera".
- Tsegulani menyu ndikuyambitsa kontena. Muthanso kuchita izi mwa kukanikiza kuphatikiza kiyi. Ctrl + Alt + T.
- Lowetsani lamulo
sudo apt kukhazikitsa openvpn yosavuta-rsa
kukhazikitsa zofunikira zonse. Pambuyo polowa, dinani Lowani. - Fotokozani chinsinsi cha akaunti ya superuser. Makhalidwe pa nthawi yolemba sikuwonetsedwa m'munda.
- Tsimikizirani kuwonjezera kwamafayilo atsopano posankha njira yoyenera.
Chitani mbali yotsatira pokhazikitsa kukhazikitsa pazida zonse ziwiri.
Gawo 2: Kupanga ndikukhazikitsa Bungwe Loyeserera
Malo achitetezowo ali ndi udindo wofufuza makiyi a anthu onse komanso amapereka chinsinsi cholimba. Amapangidwa pa chipangizo chomwe ogwiritsa ntchito ena amalumikizana, kotero tsegulani cholumikizira pa PC ndikutsatira izi:
- Choyamba, foda imapangidwa kuti isunge makiyi onse. Mutha kuyiyika kulikonse, koma ndibwino kusankha malo otetezeka. Gwiritsani ntchito lamulo
sudo mkdir / etc / openvpn / yosavuta-rsa
pati / etc / openvpn / yosavuta-rsa - malo oti apange chikwatu. - Kenako, zolemba zowonjezera zosavuta ziyenera kuyikidwa mu foda iyi, ndipo zimachitika
sudo cp -R / usr / share / mosavuta-rsa / etc / openvpn /
. - Chilolezo chotsimikizika chimapangidwa mu chikwatu chomaliza. Pitani ku foda iyi choyamba
cd / etc / openvpn / yosavuta Rsa /
. - Kenako ikani lamulo lotsatirali m'munda:
wokonda -i
# gwero ./vars
# ./clean-konse
# ./ zomanga-ca
Pakadali pano, kompyuta ya seva ikhoza kusiyidwa yokha ndikusunthira ku zida zamakasitomala.
Gawo 3: Konzani Masatifiketi Amakasitomala
Malangizo omwe mudzadziwike pansipa adzafunika kuchitika pa kompyuta iliyonse ya kasitomala kuti apange mgwirizano wolondola.
- Tsegulani chopereka ndikulemba lamulo pamenepo
sudo cp -R / usr / share / mosavuta-rsa / etc / openvpn /
kukopera zolemba zonse zofunikira. - M'mbuyomu, fayilo ya satifiketi yosiyana idapangidwa pa PC ya seva. Tsopano muyenera kukopera ndikuyikayika mufoda ndi zina. Njira yosavuta yochitira izi kudzera mwa gulu.
sudo scp username @ host: /etc/openvpn/easy-rsa/keys/ca.crt / etc / openvpn / yosavuta-rsa / makiyi
pati username @ host - adilesi ya zida zomwe kutsitsirako kumapangidwira. - Zimangopanganso kiyi yachinsinsi yachinsinsi, kuti kenako ikalumikizidwe nayo. Chitani izi popita ku chikwatu chosungira
cd / etc / openvpn / yosavuta Rsa /
. - Kupanga fayilo, gwiritsani ntchito lamulo:
wokonda -i
# gwero ./vars
# zomanga-req ZopekaZopusa pamenepa, dzina la fayilo lotchulidwa. Kiyi yomwe idapangidwa iyenera kukhala mu chikwatu chomwecho ndi mabatani ena onse.
- Zimangotumiza kiyi yopezeka yokonzedwa ndi chipangizo cha seva kuti mutsimikizire kuti izi zikugwirizana. Izi zimachitika pogwiritsa ntchito lamulo lomwelo m'mene kutsitsako kunapangidwira. Muyenera kulowa
scp /etc/openvpn/easy-rsa/keys/Lumpics.csr username @ host: ~ /
pati username @ host ndi dzina la kompyuta kutumiza, ndipo Akadachi.csr - dzina la fayilo ndi kiyi. - Pa PC ya seva, tsimikizani fungulo kudzera
./sign-req ~ / Lumpics
pati Zopusa - dzina la fayilo. Pambuyo pake, bweretsani chikalatachosudo scp username @ host: /home/Lumpics.crt / etc / openvpn / mosavuta-rsa / mafungulo
.
Pa izi, ntchito zonse zoyambirira zimatsirizidwa, zimangobweretsa OpenVPN kukhala zabwinobwino ndipo mutha kuyamba kugwiritsa ntchito kulumikizidwa kwanu kwachinsinsi ndi kasitomala amodzi kapena angapo.
Gawo 4: Konzani OpenVPN
Chitsogozo chotsatira chidzakhudza onse kasitomala ndi seva. Tigawa chilichonse malinga ndi zochita ndikuchenjeza za kusintha kwa makina, ndiye muyenera kungotsatira malangizowo.
- Choyamba pangani fayilo yosinthika pa PC ya seva pogwiritsa ntchito lamulo
zcat /usr/share/doc/openvpn/examples/samp-config-files/server.conf.gz | sudo tee /etc/openvpn/server.conf
. Mukamakonza zida zamakasitomala, fayiloyi iyeneranso kuti ipangidwe mwapadera. - Onani zomwe zimakhazikika. Monga mukuwonera, doko ndi protocol ndizofanana ndizofanana, koma palibe magawo owonjezera.
- Yendani fayilo yosinthidwa yopanga kudzera pa mkonzi
sudo nano /etc/openvpn/server.conf
. - Sitidzalowa mwatsatanetsatane pakusintha mfundo zonse, chifukwa nthawi zina zimakhala zachimodzimodzi, koma mizere yoyenera mufayilo iyenera kukhalapo, ndipo chithunzi chofanana ndi ichi:
doko 1194
proto udp
comp-lzo
dev tun
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/ca.crt
dh /etc/openvpn/easy-rsa/2.0/keys/dh2048.pem
topology subnet
seva 10.8.0.0 255.255.255.0
ifconfig-dala-ipp.txtMasinthidwe onse atatha, sungani zoikamo ndikutseka fayilo.
- Ntchito ndi gawo la seva yakwaniritsidwa. Thamanga OpenVPN kudzera pa fayilo yomwe mumapanga
openvpn /etc/openvpn/server.conf
. - Tsopano tiyeni tisiyane ndi zida zamakasitomala. Monga tanena kale, fayilo yoikika idapangidwanso pano, koma nthawi ino simakunyamulidwa, chifukwa chake lamulo limawoneka motere:
sudo cp /usr/share/doc/openvpn/examples/s samp-config-files/client.conf /etc/openvpn/client.conf
. - Yendetsani fayilo yomweyo monga tafotokozera pamwambapa ndipo onjezani mizere ili:
kasitomala
.
dev tun
proto udp
kutali 194.67.215.125 1194
solv-retry yopanda malire
wolemekezeka
kulimbikira-kiyi
kulimbikira-tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/Sergiy.crt
kiyi /etc/openvpn/easy-rsa/keys/Sergiy.key
tls-Author ta.key 1
comp-lzo
mneni 3Mukasintha, kukhazikitsa OpenVPN:
openvpn /etc/openvpn/client.conf
. - Lowetsani lamulo
khalidi
kuonetsetsa kuti makina akugwira ntchito. Pakati pazabwino zonse zomwe zikuwonetsedwa, mawonekedwe ayenera kukhalapo tun0.
Kuti muthe kuwongolera kuchuluka kwa magalimoto ndi kutsegulira intaneti kwa makasitomala onse pa PC ya seva, muyenera kuyambitsa malamulo otsatirawa limodzi.
sysctl -w net.ipv4.ip_cer = 1
iptables -A INPUT --p udp --dport 1194 -j ACCEPT
iptables -I KWA KUSINTHA -i tun0 -o eth0 -j ACCEPT
iptables -I KWA KUSUNGA -i eth0 -o tun0 -j ACCEPT
iptables -t nat -A POSTRoutING -o eth0 -j MASQUERADE
M'nkhani ya lero, adayambitsidwa kukhazikitsa ndi kukhazikitsa kwa OpenVPN pa seva ndi kasitomala. Tikukulangizani kuti mutchere khutu ku zidziwitso zomwe zikuwonetsedwa "Pokwelera" ndi zowonera zolakwika, ngati zilipo. Kuchita zotereku kumathandizira kupewa mavuto ena ndi kulumikizana, chifukwa yankho lavuto limathandizira kuti mavuto ena asamachitike.