Ubuntu – Which upstream nameservers do dnsmasq/NetworkManager use really

dnsdnsmasqnetwork-manager

I'm trying to do some troubleshooting and installing dnscrypt(-proxy) on my Laptop. I want to find out which DNS servers effectively are used by my standard Ubuntu installation (w/ NetworkManager and dnsmasq, of course). However I found the configuration of dnsmasq a maze. I couldn't find out which DNS servers it's set to query.

First, I checked /etc/resolv.conf, which, of course, is set up to query 127.0.1.1 where dnsmasq-base is listening. Ok, so time to check dnsmasq config for which servers it's set up to query. /etc/dnsmasq.d/ is empty, though, except for network-manager with a single entry: bind-interfaces. Not much help there. So I check how NetworkManager calls dnsmasq:

$ pgrep -a dnsmasq
1786 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address=127.0.1.1 --cache-size=0 --conf-file=/dev/null --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

Ok so it's not using /etc/resolv.conf, it's ignoring /etc/hosts/, it's config file is set to /dev/null and /etc/NetworkManager/dnsmasq.d is empty, too. So no clues there, either. Must fall back to some defaults or something?

Other files I found:

  • /run/NetworkManager/resolv.conf says nameserver 127.0.1.1
  • /run/resolvconf/resolv.conf says nameserver 127.0.1.1
  • /etc/resolv.conf says nameserver 127.0.1.1
  • /etc/resolvconf/base is empty, ./head only has comments
  • /var/ and /run/ have no further files named resolv.conf

Running wireshark, I can see that it's asking my home router for DNS answers (as expected). But where does it get that IP and where do I change it, without using all the other functionality of dnsmasq and NetworkManager (e.g. split DNS for VPN)?

Best Answer

Found out where that information, after is has ben received via DHCP, is kept:

/var/lib/NetworkManager/*lease

For changing those settings, refer to NetworkManager's documentation:

nmcli con modify my-office my-office ipv4.ignore-auto-dns yes ipv6.ignore-auto-dns yes
nmcli con mod test-lab ipv4.dns "8.8.8.8 8.8.4.4"
nmcli con mod test-lab ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
Related Question