Sei sulla pagina 1di 0

OPENVPN Creare una rete virtuale privata da zero.

Prima di partire essenziale che la linea ADSL dell' aitazione dove risiede il
server sia re!istrata con uno dei servizi sul "e !ratuiti #ad esempio
""".d$ndns.it% che consentono di associare ad un nome dns costante un ip
che suisce continue variazioni da parte del provider. Come una volta le navi di
notte si orientavano se!uendo la stella polare& cos' i client nel mare di internet
devono avere un ri(erimento (isso& che appunto il nome dns del server.
Per procedere& per) necessario che *
A+ il provider della linea del server non sia ,a--"e * in tal caso& a di((erenza
di altri provider& ad un ip pulico visiile su internet non corrisponde un solo
router di casa& ma un pool di router #ci) possiile col meccanismo del NA.%.
/uesto non vuol dire che tale provider sia in(eriore a!li altri& solo 0uesta
particolarit1 che iniisce la (unzione che ci interessa. /uesto vale SOLO per il
server. Esiste l' 2P pulico con ,a--"e ma se lo (anno pa!are come servizio
a!!iuntivo.
3+ il router aia la voce dns dinamico con(i!uraile. A seconda del
modem4router installato& saranno diverse le videate ed i men5& per cui o!nuno
dovr1 cercare sul "e la !uida ad hoc& per poter arrivare nella sezione dove
inserire le credenziali con cui si re!istrato al servizio d$ndns.
6n altro re0uisito essenziale trovare nel !ruppo ristretto & #ma7 8 o 9 % di
utenti che decideranno di realizzare la vpn un computer dotato di una distro
linu7& con installato openvpn ed openssh& per poter con l' aiuto di script
!enerare certi(icati e chiavi. #passo :%
;% installazione di ip<!
comando magico solito per la scrittura su Azbox
mount -o remount,rw -t ext3 /dev/hda1 /MMP
creiamo la directory /opt
mkdir -p /PLUGINS/opt
ed il mount point su /opt
mount -o bind / PLUGINS/opt /opt
copiare il file ipkg_set.tar.gz nella root (ad esempio con filezilla)
andare in console sulla root dell' AzBox e decomprimere
tar x! ipk"#$et%tar%"
editare S!"serScripts
cercare la riga
=OO.>OP.?4DA.A4us;4sda:4opt
e cambiarla con il percorso
&''(#'P()/PLUGINS/opt
lanciare
%/on*e%$h
che inserisce tra l' altro uno script che e((ettua il mount di 4opt tutte le
volte al riavvio
lanciare per un aggiornamento lista pacc#etti di ipkg$cl
%/ipk"-*+ update
%isualizzare lista
%/ipk"-*+ +i$t
installare ipkg
%/ipk"-*+ in$ta++ ipk"-opt
ria%%iare.
il tool ip<! per l' installazione dei pacchetti installato.
&a procedura per l' installazione di ipkg ' stata scritta sulla base di comandi
lanciati su una serie di AzBox (remium( con #ard disk interno ) per cui i nomi
dei de%ice cambiano rispetto ad altre guide tro%ate sul )eb.
@% installazione di Openvpn
2mportante* se dopo il riavvio al comando ip<! d1 comando non trovato&
(ar rile!!ere il pro(ile * % /root/%pro!i+e # cos' come scritto * prima
punto& poi spazio poi 4root4.pro(ile%
ipk" update
ipk" +i$t
ipk" in$ta++ openvpn
Dopo 0uesti comandi Openvpn installato. Aa va con(i!urato.
Le!!endo dal sito 6((iciale OpenVpn&
http*44openvpn.net4inde7.php4open+source4documentation4ho"to.html
possiile se!uire una con(i!urazione minimalista& molto semplice
asata su una chiave simmetrica condivisa su i due host&
che consente per) di instaurare una connessione tunnel (ra soli @ punti.
Se si ha iso!no di una con(i!urazione Server + Aulti client& allora andr1
(atto un lavoro a priori per la !enerazione di chiavi asimmetriche e
certi(icati& con una Certi(icate Authorit$ che emetter1 il tutto.

3) Benerazione chiavi & certi(icati e Certi(icate Authorit$
Bli script che consentono di !enerare chiavi e certi(icati si trovano sotto
eas$+rsa # non trovata sull' az+o7 ma su di un pc uuntu con i pacchetti
openssl e openvpn installati %
2struzioni per lanciare i comandi per la !enerazioni di chiavi e certi(icati.
Sul pc linu7 salire come root e di se!uito
per la creazione della *ertificate Aut#ority+
editare il file %ars e %erso la fine inserire i %alori corretti o di fantasia per
nazione,citt-,organizzazione, mail , etc.
vi var$
ric#iamare le %ariabili col comando+
% %/var$
lanciare clean per fare pulizia della cartella keys
%/*+ean-a++
lanciare il build$ca
%/bui+d-*a
(er creare le c#ia%i per il ser%er
%/bui+d-ke,-$erver $erver
di seguito l' output del comando, con le %arie ric#ieste, delle .uali sono state
e%idenziate .uelle pi/ importanti
rootCdes<top*4usr4share4doc4openvpn4e7amples4eas$+rsa4@.DE .4uild+<e$+server server
Beneratin! a ;D@F it =SA private <e$
............GGGGGG
.......GGGGGG
"ritin! ne" private <e$ to 'server.<e$'
+++++
Hou are aout to e as<ed to enter in(ormation that "ill e incorporated
into $our certi(icate re0uest.
Ihat $ou are aout to enter is "hat is called a Distin!uished Name or a DN.
.here are 0uite a (e" (ields ut $ou can leave some lan<
,or some (ields there "ill e a de(ault value&
2( $ou enter '.'& the (ield "ill e le(t lan<.
+++++
Countr$ Name #@ letter code% J2.K*
State or Province Name #(ull name% J=AK*
Localit$ Name #e!& cit$% JSanPaoloK*
Or!anization Name #e!& compan$% J,un<$.o"nK*
Or!anizational 6nit Name #e!& section% JK*
-ommon Name .e", ,our name or ,our $erver/$ ho$tname0 1$erver23
Name JK*
Email Address Jdavide.!olia@D;@Colimpo.comK*
Please enter the (ollo"in! 'e7tra' attriutes
to e sent "ith $our certi(icate re0uest
A challen!e pass"ord JK*
An optional compan$ name JK*
6sin! con(i!uration (rom 4usr4share4doc4openvpn4e7amples4eas$+rsa4@.D4openssl.cn(
Chec< that the re0uest matches the si!nature
Si!nature o<
.he SuLect's Distin!uished Name is as (ollo"s
countr$Name *P=2N.A3LE*'2.'
stateOrProvinceName *P=2N.A3LE*'NA'
localit$Name *P=2N.A3LE*'SanPaolo'
or!anizationName *P=2N.A3LE*',un<$.o"n'
commonName *P=2N.A3LE*'server'
emailAddress *2A8S.=2NB*'davide.!olia@D;@Colimpo.com'
Certi(icate is to e certi(ied until Dec ;M ;9*:N*FN @D;N BA. #:98D da$s%
Si"n the *erti!i*ate4 1,/n23,
1 out o! 1 *erti!i*ate re5ue$t$ *erti!ied, *ommit4 1,/n2,
Irite out dataase "ith ; ne" entries
Data 3ase 6pdated
(er creare le c#ia%i per il client0
%/bui+d-ke, client0
l' output simile a 0uello della !enerazione delle chiavi per il serverO alla
domanda Common name rispondere client0
Per il client@ se!uire una procedura analo!a& e cos' via per !li altri.
Alla (ine avremo nella cartella <e$s le nostre chiavi e i certi(icati da
disseminare tra server e client sotto 4opt4etc4openvpn4 secondo la taella
presente pi5 in asso% Dopo averlo copiato sul o7& dare al clientP.<e$ i
permessi opportuni* chmod 9DD clientP.<e$. La cosa vale anche per il
server.<e$& come si evince dalla taella. # ad P sostituire il numero del client
es.* client; &client@& etc%
dr"7r+7r+7 : root root FDN9 @DDN+;@+@D ;Q*;9 ..
+r"+++++++ ; root root MMQ @DDN+;@+@D ;Q*;M ca.<e$
+r"+r++r++ ; root root ;:D@ @DDN+;@+@D ;Q*;M ca.crt
+r"+++++++ ; root root MMQ @DDN+;@+@D ;Q*:N server.<e$
+r"+r++r++ ; root root 9MD @DDN+;@+@D ;Q*:N server.csr
+r"+r++r++ ; root root :N9N @DDN+;@+@D ;Q*FD server.crt
+r"+r++r++ ; root root : @DDN+;@+@D ;Q*FD serial.old
+r"+r++r++ ; root root ;;@ @DDN+;@+@D ;Q*FD inde7.t7t.old
+r"+r++r++ ; root root @; @DDN+;@+@D ;Q*FD inde7.t7t.attr.old
+r"+r++r++ ; root root :N9N @DDN+;@+@D ;Q*FD D;.pem
+r"+++++++ ; root root MMQ @DDN+;@+@D ;Q*8D client;.<e$
+r"+r++r++ ; root root 9Q9 @DDN+;@+@D ;Q*8D client;.csr
+r"+r++r++ ; root root : @DDN+;@+@D ;Q*8D serial
+r"+r++r++ ; root root @D @DDN+;@+@D ;Q*8D inde7.t7t.attr
+r"+r++r++ ; root root @@@ @DDN+;@+@D ;Q*8D inde7.t7t
+r"+r++r++ ; root root :MF9 @DDN+;@+@D ;Q*8D client;.crt
+r"+r++r++ ; root root :MF9 @DDN+;@+@D ;Q*8D D@.pem
+r"+r++r++ ; root root @F8 @DDN+;@+@D ;Q*8; dh;D@F.pem
dr"7++++++ @ root root FDN9 @DDN+;@+@D ;Q*8; .
Benerare i parametri per il server con l' al!oritmo Di((ie+Rellman
%/bui+d-dh
al termine dello script sar1 !enerato il (ile dh;D@F.pem & da copiare solo sul
server
.A3ELLA CON CR2AV2 E CE=.2,2CA.2
6i+ename Needed 7, Purpo$e Se*ret
ca.crt server G all clients =oot CA certi(icate NO
ca.<e$ <e$ si!nin! machine onl$ =oot CA <e$ HES
dhSnT.pem server onl$ Di((ie Rellman parameters NO
server.crt server onl$ Server Certi(icate NO
server.<e$ server onl$ Server Ue$ HES
client;.crt client; onl$ Client; Certi(icate NO
client;.<e$ client; onl$ Client; Ue$ HES
client@.crt client@ onl$ Client@ Certi(icate NO
client@.<e$ client@ onl$ Client@ Ue$ HES
client:.crt client: onl$ Client: Certi(icate NO
client:.<e$ client: onl$ Client: Ue$ HES
F% Creazione del device tun
il comando openvpn ha iso!no& oltre delle chiavi& del (ile di con(i!urazione e
del device tun& che si avvia in 0uesto modo
Copiare sotto 4D2SU@4etc4openvpn il (ile tun%ko # 0uello che uso io l' ho
prelevato 0ui http*44dre-m-7.-olia(orum.com4(orum4sho"thread.phpV
t?@;M88%
Dal (ile rar estraete solo il (ile tun.<o& il resto i!noratelo.
2l comando per caricare il modulo tun il se!uente
/$bin/in$mod -v tun%ko
Per veri(icare il corretto caricamento ese!uire i due comandi di se!uito
+$mod 8 "rep tun
tun ;DMDD ; + Live D7cMN:9DDD
dme$" 8 "rep tun
tun* 6niversal .6N 4 .AP device driver& ;.9
tun* #C% ;NNN+@DDF Aa7 Urasn$ans<$
la partenza del device tun andr1 per) inserita in uno script all' avvio. Pi5
avanti la !uida detta!liata.
8% Creazione dei (ile di con(i!urazione per il server e per i client
Sul server
Sotto 4D2SU@4etc4openvpn creare il (ile server.con( col se!uente contenuto*
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
E Sample OpenVPN @.D con(i! (ile (or E
E multi+client server. E
E E
E .his (ile is (or the server side E
E o( a man$+clients W+X one+server E
E OpenVPN con(i!uration. E
E E
E OpenVPN also supports E
E sin!le+machine W+X sin!le+machine E
E con(i!urations #See the E7amples pa!e E
E on the "e site (or more in(o%. E
E E
E .his con(i! should "or< on Iindo"s E
E or Linu743SD s$stems. =ememer on E
E Iindo"s to 0uote pathnames and use E
E doule ac<slashes& e.!.* E
E YC*ZZPro!ram ,ilesZZOpenVPNZZcon(i!ZZ(oo.<e$Y E
E E
E Comments are preceded "ith 'E' or 'O' E
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
E Ihich local 2P address should OpenVPN
E listen onV #optional%
Olocal a..c.d
E Ihich .CP46DP port should OpenVPN listen onV
E 2( $ou "ant to run multiple OpenVPN instances
E on the same machine& use a di((erent port
E numer (or each one. Hou "ill need to
E open up this port on $our (ire"all.
port ;;NF
E .CP or 6DP serverV
Oproto tcp
proto udp
E Ydev tunY "ill create a routed 2P tunnel&
E Ydev tapY "ill create an ethernet tunnel.
E 6se Ydev tapDY i( $ou are ethernet rid!in!
E and have precreated a tapD virtual inter(ace
E and rid!ed it "ith $our ethernet inter(ace.
E 2( $ou "ant to control access policies
E over the VPN& $ou must create (ire"all
E rules (or the the .6N4.AP inter(ace.
E On non+Iindo"s s$stems& $ou can !ive
E an e7plicit unit numer& such as tunD.
E On Iindo"s& use Ydev+nodeY (or this.
E On most s$stems& the VPN "ill not (unction
E unless $ou partiall$ or (ull$ disale
E the (ire"all (or the .6N4.AP inter(ace.
Odev tap
dev tun
E Iindo"s needs the .AP+Iin:@ adapter name
E (rom the Net"or< Connections panel i( $ou
E have more than one. On PP SP@ or hi!her&
E $ou ma$ need to selectivel$ disale the
E Iindo"s (ire"all (or the .AP adapter.
E Non+Iindo"s s$stems usuall$ don't need this.
Odev+node A$.ap
E SSL4.LS root certi(icate #ca%& certi(icate
E #cert%& and private <e$ #<e$%. Each client
E and the server must have their o"n cert and
E <e$ (ile. .he server and all clients "ill
E use the same ca (ile.
E
E See the Yeas$+rsaY director$ (or a series
E o( scripts (or !eneratin! =SA certi(icates
E and private <e$s. =ememer to use
E a uni0ue Common Name (or the server
E and each o( the client certi(icates.
E
E An$ P8DN <e$ mana!ement s$stem can e used.
E OpenVPN can also use a PUCS E;@ (ormatted <e$ (ile
E #see Yp<cs;@Y directive in man pa!e%.
ca 4opt4etc4openvpn4ca.crt
cert 4opt4etc4openvpn4server.crt
<e$ 4opt4etc4openvpn4server.<e$ E .his (ile should e <ept secret #chmod 9DD%
E Di((ie hellman parameters.
E Benerate $our o"n "ith*
E openssl dhparam +out dh;D@F.pem ;D@F
E Sustitute @DFM (or ;D@F i( $ou are usin!
E @DFM it <e$s.
dh 4opt4etc4openvpn4dh;D@F.pem
E Con(i!ure server mode and suppl$ a VPN sunet
E (or OpenVPN to dra" client addresses (rom.
E .he server "ill ta<e ;D.M.D.; (or itsel(&
E the rest "ill e made availale to clients.
E Each client "ill e ale to reach the server
E on ;D.M.D.;. Comment this line out i( $ou are
E ethernet rid!in!. See the man pa!e (or more in(o.
server ;D.M.D.D @88.@88.@88.D
E Aaintain a record o( client W+X virtual 2P address
E associations in this (ile. 2( OpenVPN !oes do"n or
E is restarted& reconnectin! clients can e assi!ned
E the same virtual 2P address (rom the pool that "as
E previousl$ assi!ned.
Oi(con(i!+pool+persist ipp.t7t
E Con(i!ure server mode (or ethernet rid!in!.
E Hou must (irst use $our OS's rid!in! capailit$
E to rid!e the .AP inter(ace "ith the ethernet
E N2C inter(ace. .hen $ou must manuall$ set the
E 2P4netmas< on the rid!e inter(ace& here "e
E assume ;D.M.D.F4@88.@88.@88.D. ,inall$ "e
E must set aside an 2P ran!e in this sunet
E #start?;D.M.D.8D end?;D.M.D.;DD% to allocate
E to connectin! clients. Leave this line commented
E out unless $ou are ethernet rid!in!.
Oserver+rid!e ;D.M.D.F @88.@88.@88.D ;D.M.D.8D ;D.M.D.;DD
E Con(i!ure server mode (or ethernet rid!in!
E usin! a DRCP+pro7$& "here clients tal<
E to the OpenVPN server+side DRCP server
E to receive their 2P address allocation
E and DNS server addresses. Hou must (irst use
E $our OS's rid!in! capailit$ to rid!e the .AP
E inter(ace "ith the ethernet N2C inter(ace.
E Note* this mode onl$ "or<s on clients #such as
E Iindo"s%& "here the client+side .AP adapter is
E ound to a DRCP client.
Oserver+rid!e
E Push routes to the client to allo" it
E to reach other private sunets ehind
E the server. =ememer that these
E private sunets "ill also need
E to <no" to route the OpenVPN client
E address pool #;D.M.D.D4@88.@88.@88.D%
E ac< to the OpenVPN server.
Opush Yroute ;N@.;9M.;D.D @88.@88.@88.DY
Opush Yroute ;N@.;9M.@D.D @88.@88.@88.DY
E .o assi!n speci(ic 2P addresses to speci(ic
E clients or i( a connectin! client has a private
E sunet ehind it that should also have VPN access&
E use the sudirector$ YccdY (or client+speci(ic
E con(i!uration (iles #see man pa!e (or more in(o%.
E EPAAPLE* Suppose the client
E havin! the certi(icate common name Y.heloniousY
E also has a small sunet ehind his connectin!
E machine& such as ;N@.;9M.FD.;@M4@88.@88.@88.@FM.
E ,irst& uncomment out these lines*
Oclient+con(i!+dir ccd
Oroute ;N@.;9M.FD.;@M @88.@88.@88.@FM
E .hen create a (ile ccd4.helonious "ith this line*
E iroute ;N@.;9M.FD.;@M @88.@88.@88.@FM
E .his "ill allo" .helonious' private sunet to
E access the VPN. .his e7ample "ill onl$ "or<
E i( $ou are routin!& not rid!in!& i.e. $ou are
E usin! Ydev tunY and YserverY directives.
E EPAAPLE* Suppose $ou "ant to !ive
E .helonious a (i7ed VPN 2P address o( ;D.N.D.;.
E ,irst uncomment out these lines*
Oclient+con(i!+dir ccd
Oroute ;D.N.D.D @88.@88.@88.@8@
E .hen add this line to ccd4.helonious*
E i(con(i!+push ;D.N.D.; ;D.N.D.@
E Suppose that $ou "ant to enale di((erent
E (ire"all access policies (or di((erent !roups
E o( clients. .here are t"o methods*
E #;% =un multiple OpenVPN daemons& one (or each
E !roup& and (ire"all the .6N4.AP inter(ace
E (or each !roup4daemon appropriatel$.
E #@% #Advanced% Create a script to d$namicall$
E modi($ the (ire"all in response to access
E (rom di((erent clients. See man
E pa!e (or more in(o on learn+address script.
Olearn+address .4script
E 2( enaled& this directive "ill con(i!ure
E all clients to redirect their de(ault
E net"or< !ate"a$ throu!h the VPN& causin!
E all 2P tra((ic such as "e ro"sin! and
E and DNS loo<ups to !o throu!h the VPN
E #.he OpenVPN server machine ma$ need to NA.
E or rid!e the .6N4.AP inter(ace to the internet
E in order (or this to "or< properl$%.
Opush Yredirect+!ate"a$ de(; $pass+dhcpY
E Certain Iindo"s+speci(ic net"or< settin!s
E can e pushed to clients& such as DNS
E or I2NS server addresses. CAVEA.*
E http*44openvpn.net4(a0.htmlEdhcpcaveats
E .he addresses elo" re(er to the pulic
E DNS servers provided $ opendns.com.
Opush Ydhcp+option DNS @DM.9Q.@@@.@@@Y
Opush Ydhcp+option DNS @DM.9Q.@@D.@@DY
E 6ncomment this directive to allo" di((erent
E clients to e ale to YseeY each other.
E 3$ de(ault& clients "ill onl$ see the server.
E .o (orce clients to onl$ see the server& $ou
E "ill also need to appropriatel$ (ire"all the
E server's .6N4.AP inter(ace.
Oclient+to+client
E 6ncomment this directive i( multiple clients
E mi!ht connect "ith the same certi(icate4<e$
E (iles or common names. .his is recommended
E onl$ (or testin! purposes. ,or production use&
E each client should have its o"n certi(icate4<e$
E pair.
E
E 2, HO6 RAVE NO. BENE=A.ED 2ND2V2D6AL
E CE=.2,2CA.E4UEH PA2=S ,O= EACR CL2EN.&
E EACR RAV2NB 2.S OIN 6N2/6E YCOAAON NAAEY&
E 6NCOAAEN. .R2S L2NE O6..
Oduplicate+cn
E .he <eepalive directive causes pin!+li<e
E messa!es to e sent ac< and (orth over
E the lin< so that each side <no"s "hen
E the other side has !one do"n.
E Pin! ever$ ;D seconds& assume that remote
E peer is do"n i( no pin! received durin!
E a ;@D second time period.
<eepalive ;D ;@D
E ,or e7tra securit$ e$ond that provided
E $ SSL4.LS& create an YRAAC (ire"allY
E to help loc< DoS attac<s and 6DP port (loodin!.
E
E Benerate "ith*
E openvpn ++!en<e$ ++secret ta.<e$
E
E .he server and each client must have
E a cop$ o( this <e$.
E .he second parameter should e 'D'
E on the server and ';' on the clients.
Otls+auth ta.<e$ D E .his (ile is secret
E Select a cr$pto!raphic cipher.
E .his con(i! item must e copied to
E the client con(i! (ile as "ell.
Ocipher 3,+C3C E 3lo"(ish #de(ault%
Ocipher AES+;@M+C3C E AES
Ocipher DES+EDE:+C3C E .riple+DES
E Enale compression on the VPN lin<.
E 2( $ou enale it here& $ou must also
E enale it in the client con(i! (ile.
comp+lzo
E .he ma7imum numer o( concurrentl$ connected
E clients "e "ant to allo".
Oma7+clients ;DD
E 2t's a !ood idea to reduce the OpenVPN
E daemon's privile!es a(ter initialization.
E
E Hou can uncomment this out on
E non+Iindo"s s$stems.
Ouser nood$
O!roup nood$
E .he persist options "ill tr$ to avoid
E accessin! certain resources on restart
E that ma$ no lon!er e accessile ecause
E o( the privile!e do"n!rade.
persist+<e$
persist+tun
E Output a short status (ile sho"in!
E current connections& truncated
E and re"ritten ever$ minute.
Ostatus openvpn+status.lo!
E 3$ de(ault& lo! messa!es "ill !o to the s$slo! #or
E on Iindo"s& i( runnin! as a service& the$ "ill !o to
E the YZPro!ram ,ilesZOpenVPNZlo!Y director$%.
E 6se lo! or lo!+append to override this de(ault.
E Ylo!Y "ill truncate the lo! (ile on OpenVPN startup&
E "hile Ylo!+appendY "ill append to it. 6se one
E or the other #ut not oth%.
Olo! openvpn.lo!
Olo!+append openvpn.lo!
E Set the appropriate level o( lo!
E (ile verosit$.
E
E D is silent& e7cept (or (atal errors
E F is reasonale (or !eneral usa!e
E 8 and 9 can help to deu! connection prolems
E N is e7tremel$ verose
ver D
E Silence repeatin! messa!es. At most @D
E se0uential messa!es o( the same messa!e
E cate!or$ "ill e output to the lo!.
Omute @D
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Sul client
Sotto 4D2SU@4etc4openvpn creare il (ile client.con( col se!uente contenuto*
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
E Sample client+side OpenVPN @.D con(i! (ile E
E (or connectin! to multi+client server. E
E .his con(i!uration can e used $ multiple E
E clients& ho"ever each client should have E
E its o"n cert and <e$ (iles. E
E On Iindo"s& $ou mi!ht "ant to rename this E
E (ile so it has a .ovpn e7tension E
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
E Speci($ that "e are a client and that "e
E "ill e pullin! certain con(i! (ile directives
E (rom the server.
client
E 6se the same settin! as $ou are usin! on
E the server.
E On most s$stems& the VPN "ill not (unction
E unless $ou partiall$ or (ull$ disale
E the (ire"all (or the .6N4.AP inter(ace.
Odev tap
dev tun
E Iindo"s needs the .AP+Iin:@ adapter name
E (rom the Net"or< Connections panel
E i( $ou have more than one. On PP SP@&
E $ou ma$ need to disale the (ire"all
E (or the .AP adapter.
Odev+node A$.ap
E Are "e connectin! to a .CP or
E 6DP serverV 6se the same settin! as
E on the server.
Oproto tcp
proto udp
E .he hostname42P and port o( the server.
E Hou can have multiple remote entries
E to load alance et"een the servers.
remote nome>dns>dinamico ;;NF EEEEEEE sostituire a nome>dns>dinamico il nome del server
Oremote m$+server+@ ;;NF
E Choose a random host (rom the remote
E list (or load+alancin!. Other"ise
E tr$ hosts in the order speci(ied.
Oremote+random
E Ueep tr$in! inde(initel$ to resolve the
E host name o( the OpenVPN server. Ver$ use(ul
E on machines "hich are not permanentl$ connected
E to the internet such as laptops.
resolv+retr$ in(inite
E Aost clients don't need to ind to
E a speci(ic local port numer.
noind
E Do"n!rade privile!es a(ter initialization #non+Iindo"s onl$%
Ouser nood$
O!roup nood$
E .r$ to preserve some state across restarts.
persist+<e$
persist+tun
E 2( $ou are connectin! throu!h an
E R..P pro7$ to reach the actual OpenVPN
E server& put the pro7$ server42P and
E port numer here. See the man pa!e
E i( $our pro7$ server re0uires
E authentication.
Ohttp+pro7$+retr$ E retr$ on connection (ailures
Ohttp+pro7$ Jpro7$ serverK Jpro7$ port EK
E Iireless net"or<s o(ten produce a lot
E o( duplicate pac<ets. Set this (la!
E to silence duplicate pac<et "arnin!s.
Aute+repla$+"arnin!s EEto!liere commento ad inizio ri!a
E SSL4.LS parms.
E See the server con(i! (ile (or more
E description. 2t's est to use
E a separate .crt4.<e$ (ile pair
E (or each client. A sin!le ca
E (ile can e used (or all clients.
ca ca.crt
cert client;.crt
<e$ client;.<e$
E Veri($ server certi(icate $ chec<in!
E that the certicate has the nsCert.$pe
E (ield set to YserverY. .his is an
E important precaution to protect a!ainst
E a potential attac< discussed here*
E http*44openvpn.net4ho"to.htmlEmitm
E
E .o use this (eature& $ou "ill need to !enerate
E $our server certi(icates "ith the nsCert.$pe
E (ield set to YserverY. .he uild+<e$+server
E script in the eas$+rsa (older "ill do this.
ns+cert+t$pe server
E 2( a tls+auth <e$ is used on the server
E then ever$ client must also have the <e$.
Otls+auth ta.<e$ ;
E Select a cr$pto!raphic cipher.
E 2( the cipher option is used on the server
E then $ou must also speci($ it here.
Ocipher 7
E Enale compression on the VPN lin<.
E Don't enale this unless it is also
E enaled in the server con(i! (ile.
comp+lzo
E Set lo! (ile verosit$.
ver D
E Silence repeatin! messa!es
Omute @
N.3 i (ile creati per il server ed i client sono stati realizzati a partire dei (ile di
esempio che si trovano in 4opt4etc4openvpn4sample+con(i!+(iles& e poi copiati
nella dir superiore 4opt4etc4openvpn4.
Dopo averli copiati su 4D2SU@4etc4openvpn & anche i (ile di con(i!urazione &
client con( per il client e server.con( per il server& come le chiavi private&
devono avere i permessi opportuni* lanciare sull' azo7 client
*hmod 9:: *+ient%*on!
e sul server
*hmod 9:: $erver%*on!
Dalla stessa posizione& onde evitare (unzionamenti poco sicuri involontari&
ene svuotare la cartella sample+<e$s e rimuoverla del tutto.
Nel (ile di con(i!urazione del server server.con(& una volta che si assicurato il
(unzionamento della vpn& onde evitare (reeze istantanei dovuti ad una scrittura
sull' hard dis<& ene disailitare tutti i lo!*
0uindi
assicurarsi che le se!uenti voci siano commentate& col punto e vir!ola iniziale o
il cancelletto.
Olo! openvpn.lo!
Olo!+append openvpn.lo!
Ostatus openvpn+status.lo!
Oi(con(i!+pool+persist ipp.t7t
9% Veri(ica del corretto (unzionamento della vpn
per lanciare il server
/opt/$bin/openvpn --*on!i" /;IS<=/et*/openvpn/$erver%*on!
veri(icare poi il contenuto dei due lo!*
*at openvpn%+o" 8 more
*at openvpn-$tatu$%+o"
per lanciare il client
/opt/$bin/openvpn --*on!i" /;IS<=/et*/openvpn/*+ient%*on!
lanciando a mano il comando & a video appare il lo! dell' output
una volta lanciati i comandi sui due sistemi& client e server& con i(con(i!
possiile veri(icare se l' ip della vpn stata asse!nata
i!*on!i" tun:
Lin< encap*6NSPEC RIaddr DD+DD+DD+DD+DD+DD+DD+DD+DD+DD+DD+DD+
DD+DD+DD+DD
inet addr*;D.M.D.9 P+t+P*;D.M.D.8 Aas<*@88.@88.@88.@88
6P PO2N.OPO2N. =6NN2NB NOA=P A6L.2CAS. A.6*;8DD Aetric*;
=P pac<ets*D errors*D dropped*D overruns*D (rame*D
.P pac<ets*D errors*D dropped*D overruns*D carrier*D
collisions*D t70ueuelen*;DD
=P $tes*D #D.D 3% .P $tes*D #D.D 3%
e pin!are il server * pin" 1:%>%:%1
3=AVOJstart.dK[ pin! ;D.M.D.;
P2NB ;D.M.D.; #;D.M.D.;%* 89 data $tes
9F $tes (rom ;D.M.D.;* icmp>se0?D ttl?9F time?;D9.N ms
9F $tes (rom ;D.M.D.;* icmp>se0?; ttl?9F time?9Q.: ms
9F $tes (rom ;D.M.D.;* icmp>se0?@ ttl?9F time?QD.F ms
Aiamo veri(icato che il tunnel stato realizzato.
N.3. La rete pu) essere stailita aritrariamente& nei (ile .con(
ad esempio potrei adottare la rete privata ;D.99.QQ.D& ed avere il server
;D.99.QQ.; ed i client ;D.99.QQ.8 & ;D.99.QQ.9 & ;D.99.QQ.Q etc etc
Q% 2nserimento dei comandi in esecuzione automatica sul client

creare # con vi o altro editor in un sistema linu7 %
il (ile SN;openvpnclt e metterci dentro il se!uente testo*
E\4in4sh
E
E script per l' avvio della VPN
E @DDN $ leopet
start#% S
echo Y???X Startin! module tun...Y
cd 4opt4etc4openvpn4
4sin4insmod +v 4D2SU@4etc4openvpn4tun.<o
echo Y???X Start4opt4etc4openvpnin! Openvpn...Y
4opt4sin4openvpn ++con(i! 4D2SU@4etc4openvpn4client.con(
T
stop#% S
echo Y???X Stoppin! Openvpn...Y
<illall +N openvpn
T
restart#% S
stop
start
T
case Y[;Y in
start%
start
OO
stop%
stop
OO
restart]reload%
restart
OO
-%
echo [Y6sa!e* [D Sstart]stop]restartTY
e7it ;
esac
e7it [V
Copiare il (ile SN;openvpnclt nella cartella 4D2SU@4etc4start.d del
CL2EN.; & CL2EN.@ & etc etc.
dare *hmod ?@@ SA1openvpn*+t
M% 2nserimento dei comandi in esecuzione automatica sul server
creare # con vi in un sistema linu7 %
il (ile SN;openvpnsrv e metterci dentro il se!uente testo*
E\4in4sh
E
E script per l' avvio della VPN
E @DDN $ leopet
start#% S
echo Y???X Startin! module tun...Y
cd 4D2SU@4etc4openvpn4
4sin4insmod +v 4D2SU@4etc4openvpn4tun.<o
echo Y???X Startin! Openvpn...per con(i!urazione serverY
4opt4sin4openvpn ++con(i! 4D2SU@4etc4openvpn4server.con(
T
stop#% S
echo Y???X Stoppin! Openvpn...Y
<illall +N openvpn
T
restart#% S
stop
start
T
case Y[;Y in
start%
start
OO
stop%
stop
OO
restart]reload%
restart
OO
-%
echo [Y6sa!e* [D Sstart]stop]restartTY
e7it ;
esac
e7it [V
Copiare il (ile SN;openvpnsrv nella cartella 4D2SU@4etc4start.d del SE=VE=
dare *hmod ?@@ SA1openvpn$rv
=iavviare il tutto ed il !ioco (atto. Si pu) procedere adesso con le emu che si
pre(eriscono& utilizzando de!li indirizzi privati anzich^ ip ra!!iun!iili da
internet.
N.3. ho notato che i (ile di con(i!urazione & se realizzati per pi!rizia sul pc e poi
tras(eriti con (ilezilla sull' azo7& prendono n automatico il _A (inale* (orzare
tras(erimento a inario per evitare l' inconveniente.




DIGITAL KEY SAT

Potrebbero piacerti anche