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.

After updating /etc/networking/interfaces with something very similar to below, how do I get /etc/resolv.conf to update? I tried (as root) resolver -u, service networking restart but they didn't work. I also fixed the symlink for resolv.conf and tried resolver -u again. Finally in frustration I rebooted, which did fix the problem by rebuilding /etc/resolv.conf.

Ubuntu 12.04, 64bit server, all the latest patches installed.

Please let me know the correct way.

Many thanks.

Example /etc/networking/interfaces:

iface eth0 inet static
    dns-search example.com
share|improve this question
See askubuntu.com/questions/156154/… –  user68186 Dec 3 '12 at 13:07
What were you trying to do that resolv.conf was preventing you from doing? –  kingmilo Dec 3 '12 at 14:51

4 Answers 4

up vote 36 down vote accepted

Don't do service networking restart; that's not always a reliable way of down-upping all interfaces.

The resolvconf -u command only updates resolv.conf from resolvconf's own database. You need to update the database.

To update the database you have to call resolvconf with the -a or -d option. That happens behind the scenes when you run ifup or ifdown. So, normally, as with any other change to /etc/network/interfaces, to activate changes to the dns-* options you have to ifdown the interface in question and ifup it again. Or you can reboot.

If you want to make changes to an interface without ifdownupping it (perhaps because you are administering the machine remotely and happen to be connected via that interface, natch) then you can achieve the same result by running resolvconf directly from the command line. This requires a bit more knowledge of resolvconf's semantics. Assume the relevant /e/n/i stanza is

iface IIII FFFF static
    address ...
    dns-nameservers X.X.X.X Y.Y.Y.Y
    dns-search SSSS

where FFFF is an address family ("inet" or "inet6").

To activate these dns-* options you run resolvconf as follows (yes, with newlines in the string piped to resolvconf).

echo "nameserver X.X.X.X
nameserver Y.Y.Y.Y
search SSSS" | sudo resolvconf -a IIII.FFFF

For the stanza given in the question this would be the following.

echo "nameserver
search example.com" | sudo resolvconf -a eth0.inet

Consult the resolvconf(8) manual page and the resolvconf package README file (/usr/share/doc/resolvconf/README.gz) for more information.

share|improve this answer
Thank you. Great answer. –  nslntmnx Dec 4 '12 at 3:38
"Don't do "service networking restart"; that's not a reliable way of down-upping all interfaces." Works fine for me. Good to know the clean way of doing it though. –  Aki Oct 3 '13 at 9:49
If you shouldn't do "service networking restart" can I suggest you don't put it in the first line of this question? When hurriedly looking for a solution, the first thing I did was copy and paste the first command I saw. –  Robin Winslow May 29 '14 at 9:31
@RobinWinslow +1 for making my day –  Pete Aug 5 '14 at 16:51
Thanks -- this was very helpful. –  fg nu Mar 29 at 20:47

Although the manpage isn't installed by default it's documented via the update scripts option, just run:

sudo resolvconf -u
share|improve this answer

For those of you managing your servers remotely you can:

  1. update the dns-nameservers line in /etc/network/interfaces
  2. # ifdown eth01; ifup eth01

Notice that this has to be on one line divided with ; (the linux command line separator). You should not even lose your current connection. The exception is making a typo in the interfaces file. If this happens ifup will fail and you will have to have physical access or another ethxx connection.

share|improve this answer

Also you can try this command:

cat /etc/network/interfaces |sed 's/#.*$//'|grep dns-|sed 's/dns-//g'|sudo resolvconf -a eth0.inet
share|improve this answer
Can you explain why this command should work? –  KasiyA Oct 9 '14 at 13:08

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.