I'm on Ubuntu 16.04 Xenial and Network Manager started dnsmasq for me with these options:

~/ ps awux|grep dnsmasq
nobody    2649  0.0  0.0  54488  3588 ?        S    Mai23   0:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address= --cache-size=0 --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

I'd like dnsmasq to read/use the /etc/hosts file as well, which it currently doesn't seem to, because of the option --no-hosts.

How do I change the startup options, that Network Manager uses to invoke dnsmasq?


All dnsmasq configuration files you add into /etc/NetworkManager/dnsmasq.d/ are passed to dnsmasq. Just check it with the command:

ps -ef | grep -P "dnsmasq\s"

I get this kind of result (notice the --conf-dir parameter):

nobody    6105  5868  0 20:20 ?        00:00:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/NetworkManager/dnsmasq.pid --listen-address= --cache-size=0 --clear-on-reload --conf-file=/dev/null --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

So you could just create a file e.g. /etc/NetworkManager/dnsmasq.d/my-hosts containing the declaration:


in order to use /etc/hosts (see doc). But because dnsmasq starts also with --no-hosts this might determine dnsmasq to still ignore /etc/hosts so you could just create a hard link to it e.g.:

sudo cp -al /etc/hosts /etc/my-hosts

then change the declaration to:


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.