Création d'un tunnel VPN

TableOfContents(3)

Voici un petit guide pour installer un serveur et un client OpenVPN, qui correspond à ce que j'ai (CédricProtière) mis en oeuvre à Cotonou, en utilisant http://openvpn.net/howto.html et la patience de JérômeSantini.

Sur le serveur

Initialisation

export KEY_PROVINCE=Atlantique export KEY_CITY=Cotonou export KEY_ORG="AUF" export KEY_EMAIL="root+openvpn@bj.refer.org"}}}

Création des certificats et des clés

./clean-all #a ne faire que la premiere fois ! ./build-ca}}}

Initialisation du fichier de configuration

cert /etc/openvpn/keys/server.crt key /etc/openvpn/keys/server.key dh /etc/openvpn/keys/dh1024.pem server 10.25.2.0 255.255.255.0 #Je choisis ici d'avoir comme RPV 10.25.2.0/24 push "route 10.0.0.0 255.0.0.0" #pour ajouter la route 10.0.0.0/8}}}

Mettre à jour le filtrage

# nfs-cotonou a cause de snat, sinon ca devrait etre l'ip du poste : $IPT -A INPUT -p udp --dport 1194 -s 81.91.236.4 -j ACCEPT $IPT -A OUTPUT -p udp --dport 1194 -d 81.91.236.4 -j ACCEPT

# Allow TUN interface connections to OpenVPN server ${IPT} -A INPUT -i tun+ -j ACCEPT

# Allow TUN interface connections to be forwarded through other interfaces ${IPT} -A FORWARD -i tun+ -j ACCEPT }}}

Tester

Thu Nov 23 17:20:37 2006 Diffie-Hellman initialized with 1024 bit key Thu Nov 23 17:20:37 2006 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ] Thu Nov 23 17:20:37 2006 TUN/TAP device tun0 opened Thu Nov 23 17:20:37 2006 /sbin/ifconfig tun0 10.25.2.1 pointopoint 10.25.2.2 mtu 1500 Thu Nov 23 17:20:37 2006 /sbin/route add -net 10.25.2.0 netmask 255.255.255.0 gw 10.25.2.2 Thu Nov 23 17:20:37 2006 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:23 ET:0 EL:0 AF:3/1 ] Thu Nov 23 17:20:37 2006 GID set to openvpn Thu Nov 23 17:20:37 2006 UID set to nobody Thu Nov 23 17:20:37 2006 UDPv4 link local (bound): [undef]:1194 Thu Nov 23 17:20:37 2006 UDPv4 link remote: [undef] Thu Nov 23 17:20:37 2006 MULTI: multi_init called, r=256 v=256 Thu Nov 23 17:20:37 2006 IFCONFIG POOL: base=10.25.2.4 size=62 Thu Nov 23 17:20:37 2006 IFCONFIG POOL LIST Thu Nov 23 17:20:37 2006 Initialization Sequence Completed}}}

Sur le client

ca /etc/openvpn/keys/ca.crt cert /etc/openvpn/keys/sysadmin.crt key /etc/openvpn/keys/sysadmin.key}}}

Fri Nov 24 10:04:12 2006 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port. Fri Nov 24 10:04:12 2006 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info. Fri Nov 24 10:04:12 2006 LZO compression initialized Fri Nov 24 10:04:12 2006 Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ] Fri Nov 24 10:04:12 2006 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ] Fri Nov 24 10:04:12 2006 Local Options hash (VER=V4): '41690919' Fri Nov 24 10:04:12 2006 Expected Remote Options hash (VER=V4): '530fdded' Fri Nov 24 10:04:12 2006 UDPv4 link local: [undef] Fri Nov 24 10:04:12 2006 UDPv4 link remote: 81.91.236.1:1194 Fri Nov 24 10:04:12 2006 TLS: Initial packet from 81.91.236.1:1194, sid=c77a8b68 48e5b272 Fri Nov 24 10:04:12 2006 VERIFY OK: depth=1, /C=BJ/ST=Atlantique/L=Cotonou/O=AUF/OU=CNFC/CN=fw-cotonou/emailAddress=root_openvpn@bj.refer.org Fri Nov 24 10:04:12 2006 VERIFY OK: depth=0, /C=BJ/ST=Atlantique/O=AUF/OU=CNFC/CN=server/emailAddress=root_openvpn@bj.refer.org Fri Nov 24 10:04:12 2006 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key Fri Nov 24 10:04:12 2006 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication Fri Nov 24 10:04:12 2006 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key Fri Nov 24 10:04:12 2006 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication Fri Nov 24 10:04:12 2006 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA Fri Nov 24 10:04:12 2006 [server] Peer Connection Initiated with 81.91.236.1:1194 Fri Nov 24 10:04:13 2006 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1) Fri Nov 24 10:04:13 2006 PUSH: Received control message: 'PUSH_REPLY,route 10.0.0.0 255.0.0.0,route 10.25.2.1,ping 10,ping-restart 120,ifconfig 10.25.2.6 10.25.2.5' Fri Nov 24 10:04:13 2006 OPTIONS IMPORT: timers and/or timeouts modified Fri Nov 24 10:04:13 2006 OPTIONS IMPORT: --ifconfig/up options modified Fri Nov 24 10:04:13 2006 OPTIONS IMPORT: route options modified Fri Nov 24 10:04:13 2006 TUN/TAP device tun0 opened Fri Nov 24 10:04:13 2006 ifconfig tun0 10.25.2.6 pointopoint 10.25.2.5 mtu 1500 Fri Nov 24 10:04:13 2006 route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.25.2.5 Fri Nov 24 10:04:13 2006 route add -net 10.25.2.1 netmask 255.255.255.255 gw 10.25.2.5 Fri Nov 24 10:04:13 2006 Initialization Sequence Completed}}}

Finalisation

dns-search refer.bj}}}