Update: Looks like it's avahi-dnsconfd that's adding 8.8.8.8 and 8.8.4.4 to my /etc/resolv.conf file. I found this in /var/log/syslog:

Jan  4 17:00:21 freewill nm-dispatcher: req:1 'up' [ens33]: start running ordered scripts...
Jan  4 17:00:21 freewill avahi-dnsconfd[3579]: New DNS Server 8.8.4.4 (interface: 2.IPv4)
Jan  4 17:00:21 freewill avahi-dnsconfd[3579]: New DNS Server 8.8.8.8 (interface: 2.IPv4)

How can I make Ubuntu fetch DNS servers from DHCP only and not use Avahi (mDNS) for fetching DNS servers?


I am testing out Ubuntu Mate 16.04.1 LTS, and having trouble because something keeps adding Google's DNS servers to /etc/resolv.conf:

josh@freewill:~$ 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.100.1.1
nameserver 8.8.4.4
nameserver 8.8.8.8
search my.domain.name

I don't want 8.8.4.4 nor 8.8.8.8 in /etc/resolv.conf because that breaks my local network: My local DNS server (10.100.1.1) serves DNS for local NATed services which don't have public DNS records.

If I manually edit /etc/resolv.conf and remove the Google DNS nameservers, they get added back again by a reboot or resolvconf -u

NetworkManager does not have 8.8.8.8 nor 8.8.4.4 listed under Additional DNS Servers so that's not the cause.

The system has three ethernet interfaces, only one is connected. It's on a network with a DCHP server that provides DNS information. Contents of /etc/network/interfaces is:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

I have run grep -R '8\.8\.8\.8' /etc and there's no other reference to 8.8.8.8 in any config file. Nothing under /etc/resolvconf refers to Google DNS servers, either!

Why is Ubuntu Mate adding Google DNS servers to /etc/resolv.conf and how can I make it stop? For now, I've done sudo rm /etc/resolv.conf; sudo cp /run/resolvconf/resolv.conf /etc/resolv.conf; sudo chattr +i /etc/resolv.conf but I know that in the future this will bite me...

  • Comments are not for extended discussion; the entire conversation and all comments have been moved to chat. – Thomas Ward Jan 4 '17 at 23:11
up vote 2 down vote accepted

After much investigation (with help from @Terrance) I discovered that Ubuntu Mate is using avahi-dnsconfd and some other device on my network (possibly a Raspberry Pi) was broadcasting Google's DNS servers over mDNS / Bonjor / Avahi.

avahi-dnsconfd was picking this up and when avahi-dnsconfd.action ran, it was calling resolvconf to add the DNS servers is discovered over mDNS to /etc/resolf.conf

I disabled avahi-dnsconfd using:

sudo systemctl stop avahi-dnsconfd.service
sudo systemctl disable avahi-dnsconfd.service

for good measure I also edited /etc/default/avahi-daemon and set AVAHI_DAEMON_DETECT_LOCAL=0 (because I know my network doesn't have unicast DS servers that serve the .local TLD)

You don't edit the /etc/resolve.conf file directly, it's done when you call resolvconf - u.

You should edit the file:

/etc/resolvconf/resolv.conf.d/head

instead.

Make sure that you create a backup first in case anything goes wrong:

sudo cp /etc/resolvconf/resolv.conf.d/head /etc/resolvconf/resolv.conf.d/head.backup 

Then edit it to add your DNS nameservers. This is my one, using openDNS (recommended):

bitofagoob@me:~$ cat /etc/resolvconf/resolv.conf.d/head

    # 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 208.67.222.222
    nameserver 208.67.220.220

Then run resolvconf - u and the nameserver info will be copied from the /etc/resolvconf/resolv.conf.d/head file to the /etc/resolv.conf file.

The system needs to set it up this way for it to be valid.

  • This... doesn't answer my question... – Josh Jan 4 '17 at 2:25
  • I shouldn't have bothered adding something that wasn't already included in the responses. – bitofagoob Jan 4 '17 at 2:45
  • 2
    Sorry, I didn't mean to be rude, I know you're trying to help and I appreciate that. However this doesn't answer my question about where Google's DNS servers are coming from... – Josh Jan 4 '17 at 4:22
  • Yes, my answer was tangential to your problem. I was just pointing out that if you were trying to edit resolve.conf directly it wouldn't help you get nearer to finding out what's wrong. Unfortunately I can't help you any further. I hope you find out what it is. – bitofagoob Jan 4 '17 at 17:27

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.