I am trying to connect to a VPN from Ubuntu 16.04 server edition (no GUI).

I use the downloaded configuration and connect with sudo openvpn - - config path/to/.ovpn

This seems to work fine, no errors and I get a tun interface. But I cannot seem to access external urls.

E.g. ping google.com results in a long pause then ping: unknown host google.com

A simple sendmail command fails saying it cannot connect to SMTP server (external)

Dyndns client fails to update, presumably as it can't connect with the service provider.

If I disconnect the openvpn connection the above all works fine.

I have enabled through traffic on my router (virgin media superhub) to no avail. Do I need to do any port forwarding? But none of the guides say to do so...

Thanks for any suggestions.

  • Can you ping when connected to the VPN? Does your OPenVPN connection assign a DNS server for it to say "Go query through this"? (which is why you can't ping google.com possibly, because you can't resolve its dns) – Thomas Ward Jun 15 '16 at 21:43
  • Aha... Yes I can ping! But I am unsure what that means. Shouldn't the VPN provider's config (ovpn) file take care of DNS? How do I check. Thanks for the positive answer... I'm a step closer. Funny how on GUI desktop I never had this problem – j0nr Jun 15 '16 at 22:01
  • Did you set up the VPN server? – Thomas Ward Jun 15 '16 at 22:07
  • No, it's a paid for service. Buffered VPN – j0nr Jun 15 '16 at 22:08
  • When on the VPN, use dig +short A google.com or nslookup google.com. Do you get any type of data back or does it just either do nothing or error out – Thomas Ward Jun 16 '16 at 0:31

Due to my lack of ability to follow simple instructions it seems, reviewing the setup instructions by the provider, I seemed to have missed a vital step which was to add a script to my .ovpn config to run update-resolv-conf This then fixed it.

Apologies for time wasting and many thanks to Thomas for his help and persistance.


This appears to be a DNS problem.

As was tested by the OP in comments, data can go out to the Internet from over the VPN, so the issue is that it's not getting a DNS server with which to query. We've also confirmed that DNS lookups can be done outbound. So we just need to make sure the system can always reach a DNS server.

In your /etc/resolv.conf and when you are connected to your VPN, there should be something like this at the very least (IP addresses may differ!) in the file:


If not, then we need to make sure you have a DNS server set so you can resolve domain names. So, replace the contents of /etc/resolv.conf with the following (Google DNS):


and then try and use the Internet normally over the VPN.

If you do this and it doesn't work because /etc/resolv.conf keeps getting overwritten, then you may wish to consider forcing it to be unchangeable with sudo chattr +i /etc/resolv.conf. If you are absolutely certain that you won't have to change your DNS servers, then do not make this change, because you will run into issues with DHCP or such trying to set DNS nameservers and failing because nothing can edit /etc/resolv.conf.

  • 1
    OK, you might want to kill me now...found out the problem. I had to add some lines to my .ovpn config to run update-resolv-conf as per instructions from my provider....missed that somehow, works now. <insert embarrased smiley face> Thank you so much for your effort though, I really do appreciate it. – j0nr Jun 17 '16 at 20:14
  • @j0nr Add that as an answer and accept it. You can say you made a mistake following the providers instructions, and be no worse off :) – Thomas Ward Jun 17 '16 at 20:17
  • Have the same problem, and modifying the xxx.ovpn file with update-resolv-conf did not help. It looks like my resolv.conf file is a symlink with a warning that it is being overwritten anyway, and the content is nameserver This is on 16.04 version of Ubuntu. N.B. the vpn connection process seems to do everything it is supposed to do (establish connection, set up tun0, manipulate dns, etc.) but still not getting out to the Internet. – Janos Jan 24 '17 at 19:45

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.