VPN DNS Resolving Woes in Ubuntu 12.04

If you have recently upgraded to Ubuntu 12.04, you may have experienced problems resolving hosts when using a DNS server over a VPN connection.

Here’s a likely situation… You’re finding that any hosts with a .local (or other private) suffix that are provided by the remote DNS server do not resolve. However, you can find the host by command line utilities, like nslookup and host.

Ubuntu has made significant changes to how DNS works; it’s moved to the resolvconf library for managing /etc/resolv.conf and uses dnsmasq as a local DNS resolver. Ubuntu Core developer Stéphane Graber has blogged about these changes, along with possible solutions to common problems.

In my case, after reading his blog post, I tried the solutions he provides to common problems. Nothing seemed to work. Then I stumbled across a question on Stack Overflow, which sounded strikingly similar.

It turns out that the problem is with how host names are being resolved in functions like gethostbyname(3). You could probably go through and edit /etc/nsswitch.conf like the Stack Overflow article describes, but you may not feel comfortable adjusting the file without knowing what the repercussions would be.

The real solution is to follow the recommendations from the Avahi project, which is what is causing the .local domains to resolve.

Here is a walk-through of the steps to fix this problem:

  1. Open up a terminal and edit the following file:

    sudo nano  /etc/avahi/avahi-daemon.conf
  2. Change the following line:

    #domain-name=local

    to

    domain-name=.alocal
  3. Save the file and exit: Hit Ctrl + o then Ctrl + x

  4. Restart AVAHI:

    sudo service avahi-daemon restart

You should now be able to resolve .local hosts provided by your VPN’s DNS server.

Notes

  1. Jeffrey Zellman submitted this to 403labs