Ubuntu – Openvpn and DNS

dnsnetworkingopenvpnvpn

I'm on Ubuntu 16.04 and I have setup an openvpn connection that works fine. Before starting the vpn connection, my ISP DNS is defined in /etc/resolv.conf from DHCP:

# 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 isp.x.y.z

I have added the followign lines to the openvpn configuration file:

up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

so the /etc/resolv.conf gets updated when I start the vpn connection. When started, it looks like this:

# 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 vpn.x.y.z
nameserver isp.x.y.z

with vpn.x.y.z the IP of the vpn DNS server; what I wanted. However, the line for my ISP DNS is still there. This causes a problem when running a DNS leak tests as my ISP DNS gets queried.

So I'm trying to get rid of the entry of my ISP when starting the openvpn connection. It works fine if I remove it manually but I'd like to get this automated. Any suggestion?

Thanks!

Fritz

Best Answer

From the comments...

Turn dnsmasq back on, and in your network connection profile, go to the IPv4 tab and change Automatic (DHCP) to Automatic (DHCP) addresses only and then retry your leak test.

Related Question