Résolution du problème de DNS avec OpenVPN sous Ubuntu

Date: 27/02/2015 | Catégories: Open-source,Reseau | Tags: ,,

Un petit billet à usage personnel (mais pas que) concernant un problème pour le moins gênant dans le cas ou vous essayez de monter une liaison VPN (OpenVPN) à partir d'Ubuntu 14.04.

Le symptôme

Vous avez un beau fichier .ovpn fourni par votre fournisseur de service VPN ou par votre OpenVPN server auto-hébergé. Quand vous montez le VPN avec la commande suivante:

$ sudo openvpn --config Paris.ovpn 
Fri Feb 27 21:17:12 2015 OpenVPN 2.3.6 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Jan 22 2015
Fri Feb 27 21:17:12 2015 library versions: OpenSSL 1.0.1f 6 Jan 2014, LZO 2.06
Enter Auth Username:xxx
Enter Auth Password:xxx
Fri Feb 27 21:17:21 2015 UDPv4 link local: [undef]
Fri Feb 27 21:17:21 2015 UDPv4 link remote: [AF_INET]5.196.80.160:443
Fri Feb 27 21:17:21 2015 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Fri Feb 27 21:17:25 2015 VERIFY OK: depth=1, C=GB, ST=LN, L=London, O=vpnsvc, OU=vpnsvc, CN=vpnsvc.com, name=vpnsvc, emailAddress=noc@vpnsvc.com
Fri Feb 27 21:17:25 2015 VERIFY OK: nsCertType=SERVER
Fri Feb 27 21:17:25 2015 VERIFY OK: depth=0, C=GB, ST=LN, L=London, O=vpnsvc, OU=vpnsvc, CN=vpnsvc, name=vpnsvc, emailAddress=noc@vpnsvc.com
Fri Feb 27 21:17:31 2015 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Fri Feb 27 21:17:31 2015 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Fri Feb 27 21:17:31 2015 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Fri Feb 27 21:17:31 2015 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Fri Feb 27 21:17:31 2015 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Fri Feb 27 21:17:31 2015 [vpnsvc] Peer Connection Initiated with [AF_INET]5.196.80.160:443
Fri Feb 27 21:17:33 2015 TUN/TAP device tun0 opened
Fri Feb 27 21:17:33 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Feb 27 21:17:33 2015 /sbin/ip link set dev tun0 up mtu 1500
Fri Feb 27 21:17:33 2015 /sbin/ip addr add dev tun0 10.10.10.139/27 broadcast 10.10.10.159
Fri Feb 27 21:17:33 2015 Initialization Sequence Completed

Tout semble se passer pour le mieux:

$ ping 74.125.71.94
PING 74.125.71.94 (74.125.71.94) 56(84) bytes of data.
64 bytes from 74.125.71.94: icmp_seq=1 ttl=46 time=76.9 ms
64 bytes from 74.125.71.94: icmp_seq=2 ttl=46 time=125 ms
...

sauf qu'il n'y a pas de résolution DNS !

$ ping www.google.fr
<vide inter stellaire>

La cause

C'est la faute à Ubuntu qui ne prend pas en compte les @ des serveurs DNS envoyés par le serveur VPN. Le bug est connu est référencé depuis octobre 2013 mais manifestement il n'est pas jugé important par les développeur de Canonical.

La solution

Rien de bien compliqué. Il suffit d'ajouter les 3 lignes suivant à la fin de votre fichier .ovpn (mais avant votre certificat s'il est inclus dans le fichier):

...
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
...

On se retrouve ensuite avec un VPN pleinement fonctionnel...

Partager ce billet





WordPress » Erreur

Il y a eu une erreur critique sur ce site.

En apprendre plus sur le débogage de WordPress.