1

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=127.0.1.1 --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?

Alexander Skwar
  • 653
  • 3
  • 6
  • 11
  • 1
    Possible duplicate of [Configure NetworkManager's dnsmasq to use /etc/hosts](https://askubuntu.com/questions/117899/configure-networkmanagers-dnsmasq-to-use-etc-hosts) with resolution [added here](http://askubuntu.com/a/628870/16747) – krondor May 24 '16 at 13:32
  • 2
    @krondor Thanks, this did do the trick: `echo 'addn-hosts=/etc/hosts' | sudo tee /etc/NetworkManager/dnsmasq.d/etc-hosts && sudo service network-manager restart` – Alexander Skwar May 24 '16 at 13:41

1 Answers1

0

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=127.0.1.1 --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:

addn-hosts=/etc/hosts

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:

addn-hosts=/etc/my-hosts
Adrian
  • 485
  • 1
  • 6
  • 17