Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is /etc/resolv.conf useless in Ubuntu 12.04 LTS (Precise Pangolin)?

I see that the DNS server information is stored in NetworkManager now. The nmcli command line tool can list that for you.

If I want to add one more DNS server, will adding it to /etc/resolv.conf by using the resolvconf package help?

share|improve this question
I think the command mentioned above should be nm-tool, not nmcli. –  Jesse Glick Jul 19 '13 at 17:40

14 Answers 14

up vote 78 down vote accepted

If /etc/resolv.conf contains nameserver then adding entries to /etc/resolvconf/resolv.conf.d/tail won't really do anything useful. If you are using NetworkManager then you should instead statically add nameserver addresses via network indicator Edit Connections... | Edit... | IPv4 Settings | Additional DNS servers.

If you really want to add more entries to /etc/resolv.conf, create a /etc/resolvconf/resolv.conf.d/tail and add them there.

As with every Ubuntu release, it's recommended to read the Ubuntu Release Notes, available here:

The Desktop and Common Infrastructure sections contain a link to

share|improve this answer
@stgraber, please comment on the alternative approach I found and posted below. How does it compare with adding an /etc/resolvconf/resolv.conf.d/tail file or using Network Manager? Thanks. –  Randall Cook May 8 '12 at 23:02
@stgraber What do you recommend for Ubuntu Server? I've noticed from your blog and comments that Network-Manger seems to be the best way to manage this, but doing an install of network-manager on my system would install a whole bunch of things I don't need (i.e. GUI stuff). –  Avery Chan Jun 22 '12 at 3:17
What a bout adding entries to /etc/resolvconf/resolv.conf.d/head (as per your blogpost)? –  sup Mar 12 '13 at 16:15
@AveryChan, use the "third approach" suggested by @randallcook—just add dns-nameservers to your eth0 section in /etc/network/interfaces. –  mrm Aug 26 '13 at 5:15
vi /etc/network/interfaces

This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The primary network interface
allow-hotplug eth0

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0         <<----- change this comment with the #
iface eth0 inet dhcp
share|improve this answer

resolvconf is useless. I'm on a Linux server and my IP address is static and my DNS servers are static. I do not need resolvconf or NetworkManager.

Keeping it simple is my policy when working on a server. The less complexity, the easier it'll be to manage/fix when things break.

So I did aptitude purge resolvconf and manually made sure /etc/resolv.conf isn't a symlink and just created a static file. Just in case a program tries to change the file, I did chattr +i (immutable) to /etc/resolv.conf as a precaution.

share|improve this answer
As resolvconf is part of the base system, by deleting it you are asking for trouble in the future, at upgrade time. –  jdthood Oct 29 '12 at 14:30
I agree with both the comment and the answer: consider how many problems this has caused, and how many support hours have gone into fixing this "problem", and how many IT staff have spent time looking for answers. Simple is best - I don't need my servers to be changing the DNS to something I don't want. –  Mei Jul 30 at 16:40

I just deleted a link in /etc/resolv.conf and created a regulary file with the nameservers' adresses. It works, and I don't see any reasons to use that rather strange construction that the Ubuntu developers have created.

share|improve this answer
Yes, I am not a fan of this kind of change which affects servers, adds complexity and opacity. This is core behavior that shouldn't change from release to release. –  belacq Oct 4 '13 at 15:32

Mine is running Ubuntu Server 12.04. I have made the following changes and rebooted the server (typically this can be done by only bringing down the network interface, that is, ifdown eth0 or ifup eth0).

In file /etc/resolvconf/resolv.conf.d/base I added the following entries:


I hope the above helps!

share|improve this answer

Adding my bit to the already long list, here's another way (tested on 12.04):

Edit /run/resolvconf/interface/NetworkManager to fit your needs. Here's an example:

search foobar.com example.com

Then, as stated for most of the other examples, do a sudo resolvconf -u. Now you will find your resolv.conf looking like this:

search foobar.com example.com

I still don't like the way it's implemented now (seems Ubuntu needs a service for every foo it makes), and would prefer a plain resolv.conf for sure. But this approach seems to be the best compromise for me so far. The added "localhost-NS" shouldn't hurt too much.

share|improve this answer

Note: This answer was for a rather different, pre-merge version of the Question, with a focus only on pre-pending a desired name-server.

This works pre-12.04:

Edit /etc/dhcp3/dhclient.conf and add :
prepend domain-name-servers;

(In fact, this line is already present ; all you need to do is un-comment it.)

share|improve this answer
You are so awesome! How on EARTH did you find that? –  Volomike Mar 7 '11 at 15:54
Does this work if you don't have any addresses assigned by DHCP? –  Azendale Jun 30 '11 at 23:34
If you want to learn more about the dhclient configuration you can do a man dhclient.conf to access the dhclient man page. (This is not a response to Azendale's question.) –  Christian Skjødt Aug 31 '11 at 16:01
This answer is completely wrong. First of all, the question submitter wants to add the address of an external namserver, not the address The interface configurer for an external interface is not the place to add an address for an internal nameserver. Second, the file is at /etc/dhcp, not at /etc/dhcp3. Third, since Ubuntu 12.04 such things are configured using resolvconf. –  jdthood Oct 3 '13 at 8:29
First of all -- the original question was dramatically changed by moderator merging, so my answer of course looks strange. The dhcp3 file was the location when I answered this in 2011, and even if it's not ideal, it worked. I've used this solution on multiple machines. Obviously, you would change the loopback address to the one you want to prepend. I assume most people know what a loopback is, even if they haven't read RFC6890. –  belacq Oct 4 '13 at 15:11

Below I will show you the best way that I have found since I run Ubuntu Server edition and use ifup rather than NetworkManager.

Actually for me they made this easier :) by putting it all into the /etc/network/interfaces file. The same configurations that you would have written to resolv.conf can now be in the same file as your network adapter configurations as in the example below:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        dns-search local

I hope this helps out and makes it easier as it does for me, now we can create static IP addresses and add in nameservers and dns domain all in one file :)

share|improve this answer
Thank you very much. –  Saeed Zarinfam Dec 18 '12 at 5:54
Thank you. This has become my favorite method as well. An off-topic note: it's not necessary to specify the 'network' and 'broadcast' addresses since they're automatically calculated from the 'address' and the 'netmask'. All you really need are 'address', 'netmask' and 'gateway'. –  Martijn Heemels Feb 21 at 10:16

I found another approach here that involves adding a line like the one below to /etc/dhcp/dhclient.conf:

prepend domain-name-servers x.x.x.x, y.y.y.y;

Likewise, I found a third approach here that involves adding lines to /etc/network/interfaces:

auto eth0
iface eth0 inet static
    . . .

Update: Here is the official documentation for the third approach.

share|improve this answer
I voted for this because the third approach is by far the simplest way to do this. –  Billy Moon Jul 17 '12 at 9:27
the third approach rocks! –  coma Sep 11 '12 at 11:06
It sucks that internet is full on old info - this is so simple now :) –  Mikko Ohtamaa Oct 5 '12 at 10:09
@billy I could not get the third method to work at all.. only the first one listed here, editing the dclient.conf, worked for me. –  Jeff Atwood Oct 17 '12 at 21:49
Note: Editing dhclient.conf only has any effect if dhclient is used (and it is used by both ifup and NetworkManager!) Editing /etc/network/interfaces only has any effect if ifup is used. Configuring NetworkManager connections using the NetworkManager connection editor only has any effect if NetworkManager is used. –  jdthood Oct 29 '12 at 14:26

How about:

sudo dpkg-reconfigure resolvconf

Before that, use Network Manager to change DNS adress and change Method to

Automatic (DHPC) adresses only

Then run the command above and reboot. That did the solution for me.

share|improve this answer

It sounds like you are talking about the resolvconf package.

Install the resolvconf package.


cd /etc/resolvconf/resolv.conf.d
sudo cp -p head head.orig  #backup copy, always do this
sudo nano head

The top of the file is a scary warning. The file /etc/resolv.conf is autogenerated from the contents of this file; the warning is there so it will get put in /etc/resolv.conf when /etc/resolv.conf is generated. To the end of the file, add

nameserver <ip_of_nameserver>

Press Ctrl x and answer yes to saving the file. To finish up, regenerate /etc/resolv.conf so the changes are applied right now:

sudo resolvconf -u

Then check the contents of /etc/resolv.conf to see the line you added is now there. Further, it will still be there the next time your machine boots or your network service is restarted, whichever comes first.

share|improve this answer
best answer if you ask me –  Mark Jul 2 at 10:54
easiest and works like a charm ;) –  Boris Samardžija Oct 27 at 13:19

I fixed this by changing the order of sources. I moved the dns source before mdns in /etc/nsswitch.conf:

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

You can keep your settings and still use the local caching server this way.

share|improve this answer
instead of adding entries, fix the system the is broken and giving you the info you actually want. +1. –  nelaar Feb 5 '13 at 12:30

You can edit the connection "AUTO ETH0" or whatever the name is that you use to connect in NM. You can do this by right-clicking on NM and selecting "Edit Connections...". On the IPv4 tab you can select "Automatic (DHCP) addresses only" as the "Method" and NM will allow you to set the nameserver address(es) manually even addresses are delivered over DHCP.

share|improve this answer
Thank you Frank, I did that. –  Fabio May 4 '12 at 14:34

You can use NetworkManager as stated in Frank's answer, but if you would rather manually edit /etc/resolv.conf then you can do so by deleting the symbolic link /etc/resolv.conf and creating a plain file /etc/resolv.conf with the content you want. The resolvonf utility only ever writes the file /run/resolvconf/resolv.conf.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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