2

I'm having DNS issues on a new install of Ubuntu 16.04:

kqs@mycomputer:~$ nslookup localserver
Server:     127.0.0.1
Address:    127.0.0.1#53

** server can't find localserver: NXDOMAIN

But if I specify the DNS server (or sometimes if I just wait awhile), it works:

kqs@mycomputer:~$ nslookup localserver 192.168.0.1
Server:     192.168.0.1
Address:    192.168.0.1#53

Name:   localserver.localdomain
Address: 192.168.0.24

And this is the same DNS server that shows up first in Network Manager:

kqs@mycomputer:~$ nmcli device show
IP4.ADDRESS[1]:     192.168.0.152/24
IP4.GATEWAY:        192.168.0.1
IP4.ROUTE[1]:       dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:         192.168.0.1
IP4.DNS[2]:         131.215.254.100
IP4.DNS[3]:         131.215.139.100

It seems to be the same problem as "dnsmasq sometimes resolves things, sometimes it doesn't" and "Intranet address resolution and dnsmasq", but in that solution they disable dnsmasq by commenting out the dns=dnsmasq line in /etc/NetworkManager/NetworkManager.conf.

However, I'd like to troubleshoot dnsmasq rather than bypassing it completely.

So my questions are:

  1. My understanding is that dnsmasq is a lightweight DNS server running on my computer. Presumably, the Network Manager DNS settings are used to configure dnsmasq, but ultimately it is dnsmasq that is solely responsible for handling DNS lookups (with the help of upstream DNS servers as it deems necessary). Is this correct?
  2. Can I see how dnsmasq is handling a particular DNS lookup? i.e. is it answering it from its cache? Which upstream DNS server is it forwarding it to?
  3. Can I instruct dnsmasq to use a particular DNS server for the local domain?
3

1. dnsmasq and Network Manager

As yourself from a few days in the future: your understanding is correct.

Note, however, that Network Manager launches an instance of dnsmasq as a child process (not a separate daemon) and keeps its own set of dnsmasq configuration settings.

2. Can I see how dnsmasq is handling a particular DNS lookup?

Sorry, I still don't know.

3. Can I instruct dnsmasq to use a particular DNS server for the local domain?

Yes, the --server option in dnsmasq (manpage here) allows you to specify upstream DNS servers for specific domains.

You can pass this option to Network Manager's invocation of dnsmasq. I did this by creating a file in the directory /etc/NetworkManager/dnsmasq.d/ with the contents:

server=//192.168.0.1

Normally, this line would be server=/domain/<ipaddr>; in this case the empty domain specification means "unqualified names only", such as localserver in your example (as opposed to localserver.domain).

How I fixed your immediate problem

The above change still didn't fix things. I verified that this was loaded (service NetworkManager status shows a log entry dnsmasq[<pid>]: using nameserver 192.168.0.1#53 for unqualified names), but it still returns NXDOMAIN on lookups. So I settled on the following hack:

The local machines I'm connecting to all have static IPs, so I manually specified these in a file in /etc/NetworkManager/dnsmasq.d with the contents:

address=/localserver/192.168.0.13
address=/localserve2/192.168.0.14
[...and so on...]

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.