DNS on Ubuntu

For years it’s been simple to set up DNS on a Linux machine. Just add a couple of entries to /etc/resolv.conf and you’re done.

# Use Google's public DNS servers.

But things change and now it’s not that simple. If you now edit /etc/resolv.conf on Ubuntu you’ll find that the edits are ephemeral. If you restart (or even hibernate) your machine then they’ll be overwritten by default content.

search Home

Option 1: Embracing resolvconf 

The first approach is to go all in with resolvconf.

  1. Install the resolvconf package.

    sudo apt install resolvconf
  2. Enable updates.

    # Enable updates.
    sudo resolvconf --enable-updates
    # Check that updates are enabled.
    resolvconf --updates-are-enabled
    echo $?

    The result should be a 0.

  3. Edit /etc/resolvconf/resolv.conf.d/head and add the following:


I’m using the Google name servers here, but you can replace them with your preferred servers.

  1. Restart the resolvconf service.

    sudo service resolvconf restart

Fix should be permanent.

Option 2: Removing resolvconf 

If the above approach doesn’t work for you then an alternative is to remove the resolvconf package and manage /etc/resolv.conf manually (the old way).

  1. Remove the resolvconf package.

    sudo apt purge resolvconf
  2. Delete /etc/resolv.conf (it’s probably a symlink to another file).

  3. Edit /etc/resolv.conf and add the following: