2

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)?

  • 2
    It's probably getting the DNS address(es) via DHCP. The "functionality" of NetworkManager is provided for exactly that purpose, no? You can edit the connection to use DHCP only for address/gateway info and supply alternate DNS servers there. FYI it shouldn't be necessary to sniff packets - you can use nmcli e.g. nmcli -f 'IP4.DNS' dev show – steeldriver Jun 10 '17 at 13:07
2

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"
0

We know that you obtain your IP address, DNS nameservers, etc. from a DHCP transaction with your router, switch or other access point. If yours was a static address, you would have been required to specify the DNS nameservers and you'd therefor already know the DNS servers effectively being used.

In a DHCP transaction, the DNS nameservers in the router are transferred to your connection. In fact, they may come, in turn, from the modem or internet appliance provided by your internet service provider.

You can probably specify the nameservers you prefer by accessing the administration pages of the router like this.enter image description here

As well, you can direct Network Manager to use preferred nameservers, like this: remove isp-provided dns

Since the DNS nameservers vary by connection; that is, you will receive a different DNS nameserver connected at work from the nameserver connected at home, the provided numbers are shown in /etc/NetworkManager/system-connections/foo where foo is the name of the connection. For instance, one of my connections is Wired Connection 1 and it reports, among other entries:

[ipv4]
dns=8.8.8.8;8.8.4.4;
dns-search=
ignore-auto-dns=true
method=auto
  • 2
    Thank you for your answer! However, I'm already aware of how the router sends those information to my pc as part of dhcp. My question is more about the configuration file in which dnsmasq stores that information after dhcpcd received it. I.e. where is the resolved.conf file (or similiar) that does not point to 127.0.1.1 (dnsmasq) but to the IP my router gave me for DNS (192.168.178.1) – Florian Heinle Jun 10 '17 at 16:33
  • Please see my edit above in a few minutes. – chili555 Jun 10 '17 at 20:10
  • /etc/NetworkManager/system-connections is empty for me – Florian Heinle Jun 11 '17 at 9:03
  • Is Network Manager running on your system? ps aux | grep -i network Your response implies that you have never had any connection. – chili555 Jun 11 '17 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.