Problème DNS leak openvpn

Bonsoir à tous,

Je viens de passer de Ubuntu à Debian sur mon serveur, j’ai réinstaller openvpn et remis mes anciens fichiers de configuration. Tout fonctionne bien, sauf le DNS.
Dans mon fichier .opvn, j’ai bien :

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

et j’ai toujours les fuites DNS (Free SAS) sur ipleak et dnsleaktest.com .

Il y aurait-il autre chose à faire ?

Merci par avance.

Eonelia

Qu’est censé faire ce script update-resolv-conf ?
Quelles sont les routes et que contient /etc/resolv.conf sans et avec VPN ?

Bonjour, mon update-resolv-conf est censé changer de serveur DNS (d’après ce que je comprend).
Quand je lance le vpn avec openvpn --config /etc/openvpn/openvpn/monvpn.conf
J’ai bien les 3 lignes : push DNS ...

Mon fichier update-resolv-conf.sh a des balises html par contre, je trouve ça curieux.
fichier update-resolv-cong :

#!/bin/bash
#
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
#
# Used snippets of resolvconf script by Thomas Hood and Chris Hanson.
# Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL.
#
# Example envs set from openvpn:
#
#     foreign_option_1='dhcp-option DNS 193.43.27.132'
#     foreign_option_2='dhcp-option DNS 193.43.27.133'
#     foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
#

[ -x /sbin/resolvconf ] || exit 0
[ "$script_type" ] || exit 0
[ "$dev" ] || exit 0

split_into_parts()
{
        part1="$1"
        part2="$2"
        part3="$3"
}

split_into_parts()
{
        part1="$1"
        part2="$2"
        part3="$3"
}

case "$script_type" in
  up)
        NMSRVRS=""
        SRCHS=""
        for optionvarname in ${!foreign_option_*} ; do
                option="${!optionvarname}"
                echo "$option"
                split_into_parts $option
                if [ "$part1" = "dhcp-option" ] ; then
                        if [ "$part2" = "DNS" ] ; then
                                NMSRVRS="${NMSRVRS:+$NMSRVRS }$part3"
                        elif [ "$part2" = "DOMAIN" ] ; then
                                SRCHS="${SRCHS:+$SRCHS }$part3"
                        fi
                fi
        done
        R=""
        [ "$SRCHS" ] && R="search $SRCHS
"
        for NS in $NMSRVRS ; do
                R="${R}nameserver $NS
"
        done
        echo -n "$R" | /sbin/resolvconf -a "${dev}.openvpn"
        ;;
  down)
        /sbin/resolvconf -d "${dev}.openvpn"
        ;;
 NMSRVRS=""
        SRCHS=""
        for optionvarname in ${!foreign_option_*} ; do
                option="${!optionvarname}"
                echo "$option"
                split_into_parts $option
                if [ "$part1" = "dhcp-option" ] ; then
                        if [ "$part2" = "DNS" ] ; then
                                NMSRVRS="${NMSRVRS:+$NMSRVRS }$part3"
                        elif [ "$part2" = "DOMAIN" ] ; then
                                SRCHS="${SRCHS:+$SRCHS }$part3"
                        fi
                fi
        done
        R=""
        [ "$SRCHS" ] && R="search $SRCHS
"
        for NS in $NMSRVRS ; do
                R="${R}nameserver $NS
"
        done
        echo -n "$R" | /sbin/resolvconf -a "${dev}.openvpn"
        ;;
  down)
        /sbin/resolvconf -d "${dev}.openvpn"
        ;;
esac

Maintenant j’ai un soucis, j’arrive plus à démarrer mon vpn …

J’ai le message :

Fichier monvpn.conf:

client
remote 1-fi.cg-dialup.net 443
dev tun
proto udp
auth-user-pass /etc/openvpn/openvpn/cyberghost/passwd


resolv-retry infinite
redirect-gateway def1
persist-key
persist-tun
nobind
cipher AES-256-CBC
auth MD5
ping 5
ping-exit 60
ping-timer-rem
explicit-exit-notify 2
script-security 2
up /etc/openvpn/openvpn/update-resolv-conf.sh
down /etc/openvpn/openvpn/update-resolv-conf.sh
remote-cert-tls server
route-delay 5
tun-mtu 1500
fragment 1300
mssfix 1300
verb 4
comp-lzo


ca /etc/openvpn/openvpn/cyberghost/ca.crt

cert /etc/openvpn/openvpn/cyberghost/client.crt

key /etc/openvpn/openvpn/cyberghost/client.key

J’ai le message : [code]

Sat Feb 6 11:10:47 2016 us=987238 /sbin/ip link set dev tun0 up mtu 1500
Sat Feb 6 11:10:47 2016 us=998032 /sbin/ip addr add dev tun0 local 10.129.0.218 peer 10.129.0.217
Sat Feb 6 11:10:48 2016 us=6097 /etc/openvpn/openvpn/update-resolv-conf.sh tun0 1500 1558 10.129.0.218 10.129.0.217 init
Sat Feb 6 11:10:48 2016 us=11372 WARNING: Failed running command (–up/–down): could not execute external program
Sat Feb 6 11:10:48 2016 us=11410 Exiting due to fatal error
[/code]

Bon finalement, supprimé le dossier actuel openvpn et remis le dossier sauvegardé de mon ancien Ubuntu et le VPN se lance. Mais j’ai toujours ce problème de DNS.

Fichier resolv.conf (avec VPN):

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 2a01:e00::1
nameserver 2a01:e00::2
nameserver 192.168.1.254
search lan

Fichier resolv.conf (sans VPN)

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 2a01:e00::1
nameserver 2a01:e00::2
nameserver 192.168.1.254
search lan

Fichier update-resolv-conf.sh

[code]
#!/bin/bash

Parses DHCP options from openvpn to update resolv.conf

To use set as ‘up’ and ‘down’ script in your openvpn *.conf:

up /etc/openvpn/update-resolv-conf

down /etc/openvpn/update-resolv-conf

Used snippets of resolvconf script by Thomas Hood jdthood@yahoo.co.uk

and Chris Hanson

Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.

07/2013 colin@daedrum.net Fixed intet name

05/2006 chlauber@bnc.ch

Example envs set from openvpn:

foreign_option_1=‘dhcp-option DNS 193.43.27.132’

foreign_option_2=‘dhcp-option DNS 193.43.27.133’

foreign_option_3=‘dhcp-option DOMAIN be.bnc.ch

foreign_option_4=‘dhcp-option DOMAIN-SEARCH bnc.local’

You might need to set the path manually here, i.e.

[ -x $RESOLVCONF ] || exit 0
RESOLVCONF=/sbin/resolvconf

case $script_type in

up)
for optionname in ${!foreign_option_*} ; do
option="${!optionname}“
echo $option
part1=$(echo “$option” | cut -d " " -f 1)
if [ “$part1” == “dhcp-option” ] ; then
part2=$(echo “$option” | cut -d " " -f 2)
part3=$(echo “$option” | cut -d " " -f 3)
if [ “$part2” == “DNS” ] ; then
IF_DNS_NAMESERVERS=”$IF_DNS_NAMESERVERS $part3"
fi
if [[ “$part2” == “DOMAIN” || “$part2” == “DOMAIN-SEARCH” ]] ; then
IF_DNS_SEARCH="$IF_DNS_SEARCH $part3"
fi
fi
done
R=""
if [ “$IF_DNS_SEARCH” ]; then
R=“search “
for DS in $IF_DNS_SEARCH ; do
R=”${R} $DS"
done
R=”${R}
"
fi

for NS in $IF_DNS_NAMESERVERS ; do
R="${R}nameserver $NS
"
done
#echo -n “$R” | $RESOLVCONF -p -a "${dev}"
echo -n “$R” | $RESOLVCONF -a “${dev}.inet”
;;
down)
$RESOLVCONF -d “${dev}.inet”
;;
esac

[code]

Fichier update-resolv-conf

#!/bin/bash
# 
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
#
# Used snippets of resolvconf script by Thomas Hood and Chris Hanson.
# Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL. 
# 
# Example envs set from openvpn:
#
#     foreign_option_1='dhcp-option DNS 193.43.27.132'
#     foreign_option_2='dhcp-option DNS 193.43.27.133'
#     foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
#

[ -x /sbin/resolvconf ] || exit 0
[ "$script_type" ] || exit 0
[ "$dev" ] || exit 0

split_into_parts()
{
	part1="$1"
	part2="$2"
	part3="$3"
}

case "$script_type" in
  up)
	NMSRVRS=""
	SRCHS=""
	for optionvarname in ${!foreign_option_*} ; do
		option="${!optionvarname}"
		echo "$option"
		split_into_parts $option
		if [ "$part1" = "dhcp-option" ] ; then
			if [ "$part2" = "DNS" ] ; then
				NMSRVRS="${NMSRVRS:+$NMSRVRS }$part3"
			elif [ "$part2" = "DOMAIN" ] ; then
				SRCHS="${SRCHS:+$SRCHS }$part3"
			fi
		fi
	done
	R=""
	[ "$SRCHS" ] && R="search $SRCHS
"
	for NS in $NMSRVRS ; do
        	R="${R}nameserver $NS
"
	done
	echo -n "$R" | /sbin/resolvconf -a "${dev}.openvpn"
	;;
  down)
	/sbin/resolvconf -d "${dev}.openvpn"
	;;
esac

Apparement, le script ne change pas resolv.conf …

update-resolv-conf ou update-resolv-conf.sh ?
Où vois-tu des balises HTML dans ce script ?
Le script est-il bien exécuté ?
Le serveur VPN envoie-t-il des adresses de DNS ?

En fait, avant de remettre mon dossier sauvegardé, le fichier .sh comportait du HTML (je comprend pas pourquoi).

En voyant ta réponse, tu m’as mis la puce à l’oreille. Pourquoi un fichier update-resolv-conf et update-resolv-cong.sh ?

J’ai donc modifié dans mon .conf, le chemin du script up & down, en pointant vers update-resolv-conf (et pas le .sh), et apparement ça fonctionne. J’ai plus de DNS leak. Mais d’ailleurs je comprend pas trop pourquoi … les deux scripts ont l’air similaires.

Similaires mais pas identiques ?
L’un d’eux n’est peut-être pas exécutable (permission d’exécution) ?

Je dis similaire car je suis un peu largué avec ce genre de scripts. Je comprend les grandes lignes, mais pas tout, donc si il faut, les 2 scripts avaient l’air identiques, mais ne l’étaient pas.

J’avais pensé au droit d’exécution, et j’avais bien fait un chmod +x, mais ça ne fonctionnait pas quand même. Mystère.

J’essaierai de me pencher sur les scripts pour essayer de comprendre ce qui provoquait le problème :slightly_smiling:.

Merci à toi en tout cas :slightly_smiling:.

Bonsoir,
Débutant, je découvre Linux depuis 2 mois. Je suis passé aujourd’hui de Ubuntu à Debian, et, comme toi j’avais des fuites DNS sous Debian alors que je n’en avais pas sous Ubuntu alors que j’avais bien ajouté les 3 lignes dans le fichier .opvn. J’ai fini par solutionner le “problème” de mon côté en faisant un apt-get install resolvconf.