View Full Version : Creazione vpn tra linux e windows
Ho installato openvpn nel pc di casa in cui c'è ubuntu, ho creato la chiave privata che ho chiamato 'secret key.txt' e l'ho copiata nel portatile che uso per lavoro con windows.
Ho poi configurato il file per la vpn in questo modo nel client e con i dovuti cambiamenti nel server:
# Edit this file, and save to a .ovpn extension
# so that OpenVPN will activate it when run
# as a service.
#client vpn1
# Change 'myremote' to be your remote host,
# or comment out to enter a listening
# server mode.
remote xxx.xxx.xxx.xxx
# Uncomment this line to use a different
# port number than the default of 1194.
#port 1194
# Choose one of three protocols supported by
# OpenVPN. If left commented out, defaults
# to udp.
; proto [tcp-server | tcp-client | udp]
;proto udp
# You must specify one of two possible network
# protocols, 'dev tap' or 'dev tun' to be used
# on both sides of the connection. 'tap' creates
# a VPN using the ethernet protocol while 'tun'
# uses the IP protocol. You must use 'tap'
# if you are ethernet bridging or want to route
# broadcasts. 'tun' is somewhat more efficient
# but requires configuration of client software
# to not depend on broadcasts. Some platforms
# such as Solaris, OpenBSD, and Mac OS X only
# support 'tun' interfaces, so if you are
# connecting to such a platform, you must also
# use a 'tun' interface on the Windows side.
# Enable 'dev tap' or 'dev tun' but not both!
#dev tap
dev tun
# This is a 'dev tap' ifconfig that creates
# a virtual ethernet subnet.
# 10.3.0.1 is the local VPN IP address
# and 255.255.255.0 is the VPN subnet.
# Only define this option for 'dev tap'.
ifconfig 172.16.0.2 255.255.255.252
# This is a 'dev tun' ifconfig that creates
# a point-to-point IP link.
# 10.3.0.1 is the local VPN IP address and
# 10.3.0.2 is the remote VPN IP address.
# Only define this option for 'dev tun'.
# Make sure to include the "tun-mtu" option
# on the remote machine, but swap the order
# of the ifconfig addresses.
tun-mtu 1500
ifconfig 192.168.0.5 172.16.0.2
# If you have fragmentation issues or misconfigured
# routers in the path which block Path MTU discovery,
# lower the TCP MSS and internally fragment non-TCP
# protocols.
#fragment 1300
#mssfix
# If you have set up more than one TAP-Win32 adapter
# on your system, you must refer to it by name.
#dev-node my-tap
# You can generate a static OpenVPN key
# by selecting the Generate Key option
# in the start menu.
#
# You can also generate key.txt manually
# with the following command:
# openvpn --genkey --secret key.txt
#
# key must match on both ends of the connection,
# so you should generate it on one machine and
# copy it to the other over a secure medium.
# Place key.txt in the same directory as this
# config file.
secret key.txt
# Uncomment this section for a more reliable
# detection when a system loses its connection.
# For example, dial-ups or laptops that travel
# to other locations.
#
# If this section is enabled and "myremote"
# above is a dynamic DNS name (i.e. dyndns.org),
# OpenVPN will dynamically "follow" the IP
# address of "myremote" if it changes.
;ping-restart 60
;ping-timer-rem
;persist-tun
; persist-key
; resolv-retry 86400
# keep-alive ping
ping 15
# enable LZO compression
comp-lzo
# moderate verbosity
verb 4
mute 10
Ho poi girato la porta 1194 (mi pare) nel firewall e fatto partire openvpn nel pc linux tramite '/etc/ini.d/openvpn start' ma mi manca un passaggio penso: suppongo di dover fare un forward dall'indirizzo interno della vpn alla rete locale, ma come?
PLS help!
Se dici meglio che cosa vuoi ottenere e cosa funziona e cosa no, forse posso aiutarti...
Ad ogni modo ifconfig 192.168.0.5 172.16.0.2 nn mi torna molto, dovrebbero essere 2 ip di stessa rete...
Hai ragione, ho fatto il copia-incolla di una prova che avevo fatto.
Quello che voglio ottenere è di riuscire a collegarmi nel pc linux che ha il server openvpn dall'esterno con un pc con windows xp. In questo momento il pc linux ha come indirizzo interno appunto il 192.168.0.5 quindi come dovrebbe risultare lo script dei due pc e come faccio a far partire in automatico il server openvpn?
Per rispondere alla tua domanda... cosa funziona e cosa no nulla...
Server:
dev tun
ifconfig 10.1.1.1 10.1.1.2
secret key
user nobody
group nobody
daemon
comp-lzo
verb 1
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
Inoltre nel server va aperto il fw:
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A INPUT -i ppp0 -p udp --dport 1194 -j ACCEPT # se ppp0 = link internet
Client:
remote indirizzo.del.server
dev tun
ifconfig 10.1.1.2 10.1.1.1
secret key
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
(client linux, non so se x windows cambi qualcosa)
Ma gli ip nelle righe ifconfig sono nuovi eh, non e` che ci devi mettere ip gia` usati sulle macchine x le sk di rete !
E basta cosi` gia` funziona la connessione da/per 10.1.1.1
L'errore che mi dà è questo:
Sat May 06 22:07:45 2006 us=793782 Current Parameter Settings:
Sat May 06 22:07:45 2006 us=794091 config = 'C:\Programmi\OpenVPN\config\vpn1.
ovpn'
Sat May 06 22:07:45 2006 us=794260 mode = 0
Sat May 06 22:07:45 2006 us=797898 show_ciphers = DISABLED
Sat May 06 22:07:45 2006 us=798053 show_digests = DISABLED
Sat May 06 22:07:45 2006 us=798137 show_engines = DISABLED
Sat May 06 22:07:45 2006 us=798218 genkey = DISABLED
Sat May 06 22:07:45 2006 us=798295 key_pass_file = '[UNDEF]'
Sat May 06 22:07:45 2006 us=798391 show_tls_ciphers = DISABLED
Sat May 06 22:07:45 2006 us=798468 proto = 0
Sat May 06 22:07:45 2006 us=798538 NOTE: --mute triggered...
Sat May 06 22:07:45 2006 us=798667 178 variation(s) on previous 10 message(s) su
ppressed by --mute
Sat May 06 22:07:45 2006 us=798813 OpenVPN 2.0.7 Win32-MinGW [SSL] [LZO] built o
n Apr 12 2006
Sat May 06 22:07:45 2006 us=800966 IMPORTANT: OpenVPN's default port number is n
ow 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta1
6 and earlier used 5000 as the default port.
Sat May 06 22:07:45 2006 us=801219 WARNING: --ping should normally be used with
--ping-restart or --ping-exit
Sat May 06 22:07:45 2006 us=802291 Static Encrypt: Cipher 'BF-CBC' initialized w
ith 128 bit key
Sat May 06 22:07:45 2006 us=802463 Static Encrypt: Using 160 bit message hash 'S
HA1' for HMAC authentication
Sat May 06 22:07:45 2006 us=821537 Static Decrypt: Cipher 'BF-CBC' initialized w
ith 128 bit key
Sat May 06 22:07:45 2006 us=821917 Static Decrypt: Using 160 bit message hash 'S
HA1' for HMAC authentication
Sat May 06 22:07:45 2006 us=822216 LZO compression initialized
Sat May 06 22:07:46 2006 us=440980 There is a problem in your selection of --ifc
onfig endpoints [local=192.168.0.6, remote=192.168.0.7]. The local and remote V
PN endpoints cannot use the first or last address within a given 255.255.255.252
subnet. This is a limitation of --dev tun when used with the TAP-WIN32 driver.
Try 'openvpn --show-valid-subnets' option for more info.
Sat May 06 22:07:46 2006 us=441640 Exiting
Press any key to continue...
The local and remote V
PN endpoints cannot use the first or last address within a given 255.255.255.252
subnet. This is a limitation of --dev tun when used with the TAP-WIN32 driver.
Try 'openvpn --show-valid-subnets' option for more info.
Sat May 06 22:07:46 2006 us=441640 Exiting
Press any key to continue...
Il motivo è scritto qua...
Sotto windows ogni client "brucia" quattro indirizzi ip (anche se mi sembra che dalla 2.0.5 si possa evitare la cosa), per cui server e client devono stare abbastanza "distanti". Nel caso di client win32 pero' e' ancora piu' semplice se fai partire il server in modalita' server (appunto :D) e mandi gli indirizzi al client windows via dhcp.
Qualcosa del genere dal lato server:
server 172.17.0.0 255.255.0.0
push "route 172.18.0.0 255.255.0.0"
push "route 172.19.0.0 255.255.0.0"
push "dhcp-option DNS 172.17.0.1"
push "dhcp-option DOMAIN vpn.megaditta.it"
...
e dal lato client invece solo un
client
remote 1.2.3.4
anche se ovviamente è un po' overkill per un singolo client :P
Ho sistemato leggermente e ora mi dà un altro errore (o meglio mi si blocca) che secondo me dipende dal fatto che non faccio partire correttamente la parte server nel pc linux:
Sun May 07 11:46:51 2006 us=336934 Current Parameter Settings:
Sun May 07 11:46:51 2006 us=337178 config = 'C:\Programmi\OpenVPN\config\vpn1.
ovpn'
Sun May 07 11:46:51 2006 us=337312 mode = 0
Sun May 07 11:46:51 2006 us=337400 show_ciphers = DISABLED
Sun May 07 11:46:51 2006 us=337485 show_digests = DISABLED
Sun May 07 11:46:51 2006 us=337564 show_engines = DISABLED
Sun May 07 11:46:51 2006 us=337644 genkey = DISABLED
Sun May 07 11:46:51 2006 us=337718 key_pass_file = '[UNDEF]'
Sun May 07 11:46:51 2006 us=337796 show_tls_ciphers = DISABLED
Sun May 07 11:46:51 2006 us=343596 proto = 0
Sun May 07 11:46:51 2006 us=343711 NOTE: --mute triggered...
Sun May 07 11:46:51 2006 us=343840 178 variation(s) on previous 10 message(s) su
ppressed by --mute
Sun May 07 11:46:51 2006 us=343981 OpenVPN 2.0.7 Win32-MinGW [SSL] [LZO] built o
n Apr 12 2006
Sun May 07 11:46:51 2006 us=345448 IMPORTANT: OpenVPN's default port number is n
ow 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta1
6 and earlier used 5000 as the default port.
Sun May 07 11:46:51 2006 us=345651 WARNING: --ping should normally be used with
--ping-restart or --ping-exit
Sun May 07 11:46:51 2006 us=346745 Static Encrypt: Cipher 'BF-CBC' initialized w
ith 128 bit key
Sun May 07 11:46:51 2006 us=346909 Static Encrypt: Using 160 bit message hash 'S
HA1' for HMAC authentication
Sun May 07 11:46:51 2006 us=347410 Static Decrypt: Cipher 'BF-CBC' initialized w
ith 128 bit key
Sun May 07 11:46:51 2006 us=347698 Static Decrypt: Using 160 bit message hash 'S
HA1' for HMAC authentication
Sun May 07 11:46:51 2006 us=347996 LZO compression initialized
Sun May 07 11:46:51 2006 us=806124 TAP-WIN32 device [Connessione alla rete local
e (LAN) 2] opened: \\.\Global\{C40BF402-9260-4347-A8C3-2325EAE35D0B}.tap
Sun May 07 11:46:51 2006 us=806596 TAP-Win32 Driver Version 8.1
Sun May 07 11:46:51 2006 us=806828 TAP-Win32 MTU=1500
Sun May 07 11:46:51 2006 us=807084 Notified TAP-Win32 driver to set a DHCP IP/ne
tmask of 192.168.0.21/255.255.255.252 on interface {C40BF402-9260-4347-A8C3-2325
EAE35D0B} [DHCP-serv: 192.168.0.22, lease-time: 31536000]
Sun May 07 11:46:51 2006 us=817851 Successful ARP Flush on interface [4] {C40BF4
02-9260-4347-A8C3-2325EAE35D0B}
Sun May 07 11:46:51 2006 us=888703 Data Channel MTU parms [ L:1545 D:1450 EF:45
EB:135 ET:0 EL:0 AF:3/1 ]
Sun May 07 11:46:51 2006 us=889234 Local Options String: 'V4,dev-type tun,link-m
tu 1545,tun-mtu 1500,proto UDPv4,ifconfig 192.168.0.22 192.168.0.21,comp-lzo,cip
her BF-CBC,auth SHA1,keysize 128,secret'
Sun May 07 11:46:51 2006 us=889609 Expected Remote Options String: 'V4,dev-type
tun,link-mtu 1545,tun-mtu 1500,proto UDPv4,ifconfig 192.168.0.21 192.168.0.22,co
mp-lzo,cipher BF-CBC,auth SHA1,keysize 128,secret'
Sun May 07 11:46:51 2006 us=890016 Local Options hash (VER=V4): '7e51433b'
Sun May 07 11:46:51 2006 us=890259 Expected Remote Options hash (VER=V4): '40aaa
c60'
Sun May 07 11:46:51 2006 us=890590 Socket Buffers: R=[8192->8192] S=[64512->6451
2]
Sun May 07 11:46:51 2006 us=890884 UDPv4 link local (bound): [undef]:1194
Sun May 07 11:46:51 2006 us=891103 UDPv4 link remote: 82.50.xxx.xxx:1194
Ti si blocca proprio in quel punto li' ?
Sembra che le due macchine non si vedano :mbe:, potrebbe essere un problema di firewall ?
Ti consiglio anche di aggiungere la riga
nobind
dal lato client, cosi' che usi una porta alta a caso invece che la 1194 in uscita.
Ho provato anche con nobind ma non funziona. Il mio dubbio rimane comunque a lato server: considerando che non ho un firewall software attivo (iptables se non sbaglio) che comando devo dare e dove devo posizionare il file di configurazione per far partire correttamente la parte server?
Ho sistemato un pò di cose ed ora il messaggio di errore che dà è questo:
failed to obtain options consistency in
fo from peer -- this could occur if the remote peer is running a version of Open
VPN before 1.5-beta8 or if there is a network connectivity problem, and will not
necessarily prevent OpenVPN from running (0 bytes received from peer, 0 bytes a
uthenticated data channel traffic) -- you can disable the options consistency ch
eck with --disable-occ.
Ho sistemato un pò di cose ed ora il messaggio di errore che dà è questo:
failed to obtain options consistency in
fo from peer -- this could occur if the remote peer is running a version of Open
VPN before 1.5-beta8 or if there is a network connectivity problem, and will not
necessarily prevent OpenVPN from running (0 bytes received from peer, 0 bytes a
uthenticated data channel traffic) -- you can disable the options consistency ch
eck with --disable-occ.
:mbe:
Riesci a riportare le configurazioni di entrambi, client e server ?
Se ti puo' servire, le seguenti le seguenti sono le configurazioni che uso per collegare diversi client Windows 2000/2003 ad un server FreeBSD.
Il posto dove deve andare il file di configurazione dipende dalla distribuzione. Sotto windows sarà di solito c:\programmi\openvpn\config, in ogni caso per toglierti il dubbio lancia i comandi da shell, ad esempio
openvpn --config /usr/local/etc/vpn.conf
Lato server (modulo alcuni parametri extra come file di log etc.)
# Which local IP address should OpenVPN
# listen on? (optional)
local a.b.c.d
ca ca-cert.crt
cert cert.crt
key key.key
server 172.17.0.0 255.255.0.0
port 1194
dev tun0
fragment 1300
mssfix
proto udp
dh dh1024.pem
cipher BF-CBC # Blowfish (default)
Lato client:
client
dev tun
proto udp
remote x.x.x.x 1194
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
cipher BF-CBC
Inoltre, che versioni do Openvpn usi dai due lati ?
Fermi tutti, funziona! Si connette correttamente e va tutto a buon fine. Era un problema di firewall hardware che non aveva preso correttamente le impostazioni :mad: (quello del router per capirci) ma non riesco a fare nulla una volta connesso. Non riesco a fare un ping, a connettermi tramite il vnc, etc.
Domani mattina proverò ulteriormente in modo da capire più dettagliatamente il problema. Intanto grazie!
Quello che devo fare se non sbaglio è abilitare iptables e dirgli che tutto il traffico proveniente dall'indirizzo interno della vpn (se non sbaglio dovrebbe essere il 192.168.0.22) possa vedere qualsiasi cosa della rete lan.
I miei problemi sono due: dove trovo il file di configurazione di iptables e che comandi vanno inseriti?
Ho trovato uno scriptino ma mi fa il forward solo di una porta specifica :(
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.