I've read that I should have nameserver in my /etc/resolv.conf file only if my machine has its own DNS server. Since it doesn't, having it causes problems. But no matter what I do I can not get rid of it!

Here are the things I've done so far:

  1. Adding nameserver to /etc/resolvconf/resolv.conf.d/base file. ( is our network's DNS).
  2. Running: sudo resolvconf --enable-updates.
  3. Running: sudo resolvconf -u.
  4. Running: sudo service network-manager restart (just to make sure).

Yet when I open the /etc/resolv.conf file it says: nameserver! Does anyone have any idea what's wrong?

Please note that it's actually! And I have no idea why it's not!

Even when I update the /etc/resolv.conf manually and change it to anything else, the sudo resolvconf -u will revert it back to! Where is this address coming from?

up vote 94 down vote accepted

NetworkManager is the program which (via the resolvconf utility) inserts address into resolv.conf. NM inserts that address if an only if it is configured to start an instance of the dnsmasq program to serve as a local forwarding nameserver. That dnsmasq instance listens for queries at address

If you do not want to use a local forwarding nameserver then configure NetworkManager not to start a dnsmasq instance and not to insert that address. In /etc/NetworkManager/NetworkManager.conf comment out the line dns=dnsmasq

sudo nano /etc/NetworkManager/NetworkManager.conf


and restart the NetworkManager service.

sudo service network-manager restart

In this mode, NetworkManager updates /etc/resolv.conf (still via resolvconf) to include the nameserver addresses NetworkManager has for active connections.

If you want to disable the resolvconf mechanism for updating resolv.conf and just use a static resolv.conf file, do the following.

sudo rm -f /etc/resolv.conf  # Delete the symbolic link
sudo nano /etc/resolv.conf   # Create static file

# Content of static resolv.conf
  • I have 3 DNS and the query is never reaching the 3rd if I disable dnsmasq, any tip? I want to query Google, then query the intranet dns. Thanks – JorgeeFG Sep 14 '15 at 17:51
  • 3
    restart network-manager does not work on Xenial as it uses systemd instead of upstart. try systemctl restart network-manager – Matthias Weiler Jul 20 '16 at 7:15
  • My question is the dnsmasq program will ask which DNS server? it'll ask the DHCP's DNS server for the host IP address query? – Clock ZHONG Jun 11 '17 at 9:45

It is possible that resolvconf is misconfigured. This is especially likely if you have been playing around with its configuration files without really understanding how resolvconf and NetworkManager work.

For background information, please read the resolvconf documentation and Stéphane Graber's blog post.


First you should know that both Ubuntu Desktop and Ubuntu Server by default have resolvconf installed and activated. Resolvconf provides a framework for dynamically updating the /etc/resolv.conf file in an orderly and reversible way.

Second you should know that Ubuntu Desktop by default has NetworkManager installed and activated. By default NetworkManager starts an instance of dnsmasq to serve as a local forwarding nameserver. This NetworkManager-controlled dnsmasq instance listens for queries at When NetworkManager starts the dnsmasq instance it tells resolvconf to insert the address into resolv.conf. As mentioned in another answer, if you configure NetworkManager not to start a local forwarding nameserver instance then it will not start a local forwarding nameserver and will not tell resolvconf to insert the address into resolv.conf.

This default configuration works properly, so unless your situation is special you should restore the default configuration.

To restore the default configuration, see to it that

  • /etc/resolvconf/resolv.conf.d/head contains only the resolvconf header text consisting of two lines starting with a # character
  • /etc/resolvconf/resolv.conf.d/base is an empty file
  • /etc/resolvconf/resolv.conf.d/tail is an empty file
  • /etc/resolv.conf is a symbolic link with content ../run/resolvconf/resolv.conf

To achieve this, execute the following commands.

sudo su
dpkg-reconfigure resolvconf   # And answer `Yes` to agree to dynamic updates
cd /etc/resolvconf/resolv.conf.d
echo '# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
rm -f base tail original
:> base
:> tail

The original configuration of NetworkManager is to have


in /etc/NetworkManager/NetworkManager.conf. It is a reasonable choice to disable the NetworkManager-controlled local forwarding nameserver by commenting out the dns=dnsmasq line.


After doing all this it is advisable to restart the machine in order to clear out stale nameserver information records.

sudo reboot

In my case there was no dns=dnsmasq line in /etc/NetworkManager/NetworkManager.conf file and /etc/resolv.conf was still overwritten by Network Manager to have only nameserver

The fix was to restore a symlink for proper updating:

sudo ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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