Resolve DNS using VPN (openconnect) rather than default-ISP DNS on Ubuntu 18.04

Ubuntu 18.04 has a nice GNOME GUI for VPN, but it still takes a little effort to get it fully working. Here is what I did:

I connect to a VPN that is based on Cisco AnyConnect, which means that I must use OpenConnect and that is not installed by default. Fortunately, Ubuntu has some useful documentation ( that points out which packages to install. I used the following commands to install OpenConnect for Network Manager:

sudo apt-get install network-manager-openconnect
sudo apt-get install network-manager-openconnect-gnome

Once that is done, then I can setup my VPN connection.

  1. Open “Settings” -> “Network”
  2. In the VPN-section, click the “+”
  3. Select “Cisco AnyConnect Compatible VPN (openconnect)”
  4. Give the VPN a sensible name, write the URL to the VPN in the “Gateway” field and leave the rest as default. This is sufficient in my case.
  5. Now you can turn the VPN “on” by clicking “off” in “Settings” -> “Network”.

However, when the VPN is turned on, it fails to use the DNS from the VPN which means that I cannot access the internal websites behind the VPN unless I know the IP-adresses. I have tried many different solutions that didn’t work until I found something useful ( Do the following:

  1. sudo gedit /etc/NetworkManager/system-connections/<NAME_OF_YOUR_VPN_CONNECTION>
  2. Add the following to the “[ipv4]” section: dns-priority=-1
  3. Restart the network manager: sudo systemctl restart NetworkManager.service

I hope that this guide saved you from having to read page after page of solutions that does not work – I wasted enough time on that 🙂

Published by Anders Aaberg

IT-development consultant at Nine A/S MSc. Advanced Computer Science @ University of Leeds, UK

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *