3

Ubuntu 16.04

After moving office I set the DNS settings via Network GUI (see here) to my new values. Internet connection is there, but name resolution seems very slow. My interpretation is, it tries to name-resolve with old settings which times-out after around 5 sec, then tries and succeeds (fast) with new settings.

But whatever I do, the old values are always "in the system" somehow.

After a reboot:

  • /etc/resolvconf/resolv.conf.d/head contains the old DNS addresses
  • /etc/resolvconf/resolv.conf.d/base contains the new DNS addresses
  • /etc/resolv.conf (run/resolvconf/resolv.conf) contains old DNS addresses (from head) followed by values in /run/resolvconf/interface/NetworkManager (which contains localhost and search-parameter)

/etc/network/interfaces does not contain much:

auto lo
iface lo inet loopback

I added the new DNS settings into /etc/dhcp/dhclient.conf without effect.

The only remedy so far is to manually edit /etc/resolv.conf after each boot.

So, question: how can I make Ubuntu forget the old settings (the ones in /etc/resolvconf/resolv.conf.d/head which are auto-generated). No nscd installed. This would seem one way to do it, but I guess there must be a better one.

Not tried option: install dnsmasq and configure as described here (again I think it should be possible without that)

tokosh
  • 185
  • 3
  • 12
  • 1
    That message in /etc/resolvconf/resolv.conf.d/head is used for the file /etc/resolv.conf. If you remove any lines from the head file they should not return. The first line in the head file is talking about the /etc/resolv.conf file that gets generated when you run sudo resolvconf -u. – Terrance Dec 21 '17 at 03:21
  • @Terrance: I will have a try. The reason I didn't is because that file too has the message DO NOT EDIT THIS FILE BY HAND. So in my thinking whatever I do, next time I have issues this file will contain the old info too. – tokosh Dec 21 '17 at 05:20
  • @Terrance: It worked. /etc/resolv.conf is missing the base content but at least the wrong settings are gone. If you want you can write this as an answer. – tokosh Dec 21 '17 at 09:58

1 Answers1

2

The /etc/resolv.conf file is generated from the files stored in the /etc/resolvconf/resolv.conf.d directory when sudo resolvconf -u is ran.

If you make any changes to these files:

terrance@terrance-ubuntu:/etc/resolvconf/resolv.conf.d$ ls -l
total 8
-rw-r--r-- 1 root root   0 Jun  3  2015 base
-rw-r--r-- 1 root root 151 Feb 25  2017 head
-rw-r--r-- 1 root root  33 Jun  5  2016 original
-rw-r--r-- 1 root root   0 Jun  5  2016 tail

The changes will be reflected when you run the resolvconf -u command for update. I actually put my DNS information in the original file and I leave all the other files alone:

terrance@terrance-ubuntu:/etc/resolvconf/resolv.conf.d$ cat original 
search local
nameserver 10.0.0.1

Then after running the sudo resolvconf -u command we can see my changes in my /etc/resolv.conf file:

$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.0.1
search local

EDIT: One more thing you may have to check and change is the line dns=dnsmasq found in the /etc/NetworkManager/NetworkManager.conf file. You can copy and paste the following line to disable using the dnsmasq from the NetworkManager.

sudo sed -i 's/dns=dnsmasq/#dns=dnsmasq/' /etc/NetworkManager/NetworkManager.conf 

After running the above line, reboot the computer for the new changes to take effect.

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • I have your same files, but my /etc/resolv.conf file doesn't get the "original" part. I've always had problems with this overly complex dns structure... I find it Windows-like... if it works, it works, if it breaks, hours of troubleshooting are required and there is no guarantee that a solution will be found. – Avio May 20 '18 at 17:41
  • @Avio You might need to make sure that NetworkManager is not taking over the DNS either. Check the edit I just added. Also, these steps I have only verified in Ubuntu 16.04 LTS. – Terrance May 20 '18 at 18:34