Just learning about networking.

I'm on Mint-18. Use network-manager. dnsmasq is enabled.

I would like addresses that end with a particular domain-name to get resolved through a private-nameserver.

When I add a private-nameserver using the server option to the dnsmasq configuration file, everything fails. I can't even resolve google.com:

> nslookup google.com
;; connection timed out; no servers could be reache

If I remove the server option and add the same private-nameserver to the top of \etc\resolve.conf, restart network-manager things work again and I can resolve private-hosts names.

> nslookup abcprivate.net
Server:     nn.nn.nn.nn
Address:    nn.nn.nn.nn#53

Non-authoritative answer:
Name:   abcprivate.net
Address: mm.mm.mm.mm

So I know that the private-nameserver is correct. So it must be the way I'm configuring dnsmasq.

Here is my config file

>cat /etc/NetworkManager/dnsmasq.d/dnsmasq.conf
server=/abcprivate.net/nn.nn.nn.nn

where abcprivate.net is the domain of the private network, and nn are digits.

up vote 2 down vote accepted

It turned out that my settings were correct but they weren't being used.

>ps ax | grep dnsmasq
 1273 ?        S      0:00 /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

As can be seen it wasn't using the conf file...I did a few other tests to make sure that was the case.


I did end up solving the problem, but I did it by:

  • Disabling Network-manager dnsmasq plugin: comment out dns line in /etc/NetworkManager/NetworkManager.conf
  • Moving the /etc/NetworkManager/dnsmasq.d/dnsmasq.conf to /etc/dnsmasq.conf
  • Adding a catch all name server to the /etc/dnsmasq.conf (see bellow for file listing)
  • Adding the dnsmasq address to the top of the /etc/resolve.conf (by changing /etc/resolvconf/resolv.conf.d/head file...see bellow for file listing)
  • Starting dnsmasq such that it won't read the resolve.conf: dnsmasq -d -R -q (I wanted to log the queries on the screen so that I could see what was going on).
  • One I had everything working I encapsulated the dnsmasq in a systemD unit-file

$ cat /etc/dnsmasq.conf
cache-size=1000
listen-address=127.0.1.1
server=8.8.8.8
server=/abcprivate.net/nn.nn.nn.nn
cache-size=1000

$ cat /etc/resolvconf/resolv.conf.d/head    
nameserver 127.0.1.1

$ cat /etc/systemd/system/dnsmasq.service
[Unit]
Description=SystemD - Dnsmasq is a Domain Name System (DNS) forwarder
Requires=network-manager.service

[Service]
Type=simple
ExecStart=/usr/sbin/dnsmasq -d -q -R
  • I followed you solution and I was trying to add dnsmasq to systemD like you have in /etc/systemd/system/dnsmasq.service but it doesn't start on reboot > sudo systemctl status dnsmasq.service ● dnsmasq.service - SystemD - Dnsmasq is a Domain Name System (DNS) forwarder Loaded: loaded (/etc/systemd/system/dnsmasq.service; static; vendor preset: enabled) Drop-In: /run/systemd/generator/dnsmasq.service.d └─50-dnsmasq-$n Any advice ... ? – Radu Gabriel Jun 27 '17 at 16:52
  • @RaduGabriel Sorry I don't know...it may not start automatically but you can always start it manually. The important thing for me was to dnsmasq to work. – hba Jun 29 '17 at 18:48

I know this thread is stale but just in case it helps anyone, the /etc/NetworkManager/dnsmasq.c/dnsmasq.conf is ignored for many if not all parameters because some of them are hardcoded in NetworkManager source code. See this post: http://shiliangya.blogspot.com/2016/02/networkmanager-conflict-with-dns-cahing.html and also because one of the hardcoded settings is conf-file=/dev/null which prevents a conf-file from being read, even if the parameter for the conf-file-dir is also set.

I believe dnsmasq can do what you want, but it also sounds like you've got some problems with dnsmasq.conf

You probably need this line uncommented in dnsmasq.conf:

resolv-file=/etc/dnsmasq.resolv

Then you need a file /etc/dnsmasq.resolv with some other nameserver in it. I've got this:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 4.3.2.1

Further, I think you need lines somewhat like these in /etc/dnsmasq.conf:

server=/.intranet/10.0.0.3
server=/0.0.10.in-addr.arpa/10.0.0.3
local=/.intranet/

The first one sets the IP address server for the ".intranet" domain. My original DSL modem used 10.0.0.0/24 addresses inside, so that's what I've got today. The 2nd line lets you look up hostnames from IP addresses. The third line tells dnsmasq to look up fully qualified names in ".intranet" domain in /etc/hosts, or from what clients register in dnsmasq DHCP. 10.0.0.3 is the IP address of the machine running dnsmasq.

To summarize: dnsmasq.resolv sets the IP address that dnsmasq will forward other names to. The server and local settings determine the IP address of a DNS server for a particular domain, and where to get addresses for names in that domain.

  • Thank you. But i wasn't able to use your answer. I could not configure dnsmasq as a plugin to network manager. – hba Nov 16 '16 at 4:05

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.