9

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...

Josh
  • 473

2 Answers2

1

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)

Josh
  • 473
-1

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.

waltinator
  • 37,856