DNS leak with OpenVPN

I solved the problem but the solution is ugly... :nauseated_face:

Thanks to:

The solution is to create two scripts: /etc/openvpn/updns:

#!/bin/sh
mv /tmp/resolv.conf.auto /tmp/resolv.conf.auto.hold
echo $foreign_option_1 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' > /tmp/resolv.conf.auto
echo $foreign_option_2 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' >> /tmp/resolv.conf.auto
echo $foreign_option_3 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' >> /tmp/resolv.conf.auto

and /etc/openvpn/downdns:

#!/bin/sh
mv /tmp/resolv.conf.auto.hold /tmp/resolv.conf.auto

And add them to .ovpn files with this:

script-security 2 system
up "/etc/openvpn/updns"
down "/etc/openvpn/downdns"

Pretty ugly... :sneezing_face:

I understand the /etc/openvpn/updns script update DNS in the file /tmp/resolv.conf.auto but what is $foreign_option_1, $foreign_option_2 and $foreign_option_3? :face_with_raised_eyebrow:

And why the DNS are not updated automatically? :face_with_raised_eyebrow:

If anyone knows... :sweat_smile:

1 Like