I'm using Elementary OS. I've followed a dozen suggestions from different websites and nothing helps.

I use OpenVPN client to connect to an office network. The company I work for has provided me the .ovpn and other files necessary for configuring OpenVPN client.

Per OpenVPN log files, I am able to connect to the VPN just fine. Indeed, I can ping IP addresses from the office network. I can also see the VPN's nameserver address is being pushed from the server: Mon Apr 20 23:46:07 2015 us=296304 PUSH: Received control message: 'PUSH_REPLY,topology subnet,dhcp-option DNS {{nameserver IP is shown here}},route-gateway <REDACTED>,route <REDACTED> <REDACTED>,....

However no office hosts resolve.

If I run nslookup {{hostname}}, it says "server can't find {{hostname}}: NXDOMAIN". If I run nslookup {{hostname}} {{VPN nameserver address}}, it resolves the name just fine.

So, why isn't NetworkManager or whatever handles DNS queries on my system using the VPN nameserver, and how do I get it to work?

Output of nslookup askubuntu.com:


Non-authoritative answer:
Name:   askubuntu.com
Name:   askubuntu.com
Name:   askubuntu.com
Name:   askubuntu.com
Name:   askubuntu.com
  • I'm presuming this is a TAP setup, not TUN?
    – toxefa
    Apr 21 '15 at 12:23
  • Do you have the update-resolv-conf script at /etc/openvpn/ ?
    – Torin
    Feb 26 '18 at 11:11

I believe the best solution is choosing this openvpn easy-setup by using the following command:

wget git.io/vpn ; chmod 777 vpn ; ./vpn

This script auto-detects the IP address of the machine it is run on, lets you choose the DNS, protocol, and port. The rest is done for you. I recommend this because you can choose the DNS: "System default resolvers" This lets you use the nameservers in /etc/resolv.conf. To change these, just do:

nano resolv.conf

and change nameserver $IP to nameserver (Your DNS).

Keep in mind that the nameservers reset at boot, but I do have a solution for this. The easiest way that I know of is using:

nano /etc/bashrc

and adding the following line anywhere in the file:

echo (Insert your nameserver) >> /etc/resolv.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.