How do I restart dnsmasq?

I can’t figure out how to restart dnsmasq.

service dnsmasq restart
dnsmasq: unrecognized service

SOLUTION

Restart the network manager (his parent)

sudo service network-manager restart
Asked By: Rucent88

||

In the normal Ubuntu destktop configuration, dnsmasq is invoked via the NetworkManager, and can be restarted by restarting the network-manager service instead i.e.

$ pstree -sp $(pidof dnsmasq)
init(1)───NetworkManager(7731)───dnsmasq(7743)
$ 
$ sudo service network-manager restart
network-manager stop/waiting
network-manager start/running, process 7940
$ 
$ pstree -sp $(pidof dnsmasq)
init(1)───NetworkManager(7940)───dnsmasq(7953)
Answered By: steeldriver

I seem to have two instances of dnsmasq running on my Ubuntu 12.04. The following seems to work to restart both of them:

$ sudo service network-manager restart
$ sudo stop lxc-net; sudo start lxc-net

Example result:

$ for p in $(pgrep dnsmasq); do pstree -spu $p; done
init(1)───NetworkManager(19343)───dnsmasq(19417,nobody)
init(1)───dnsmasq(19623,lxc-dnsmasq)

$ sudo service network-manager restart
network-manager stop/waiting
network-manager start/running, process 20048

$ for p in $(pgrep dnsmasq); do pstree -spu $p; done
init(1)───dnsmasq(19623,lxc-dnsmasq)
init(1)───NetworkManager(20048)───dnsmasq(20066,nobody)

$ sudo stop lxc-net; sudo start lxc-net
lxc-net stop/waiting
lxc-net start/running

$ for p in $(pgrep dnsmasq); do pstree -spu $p; done
init(1)───NetworkManager(20048)───dnsmasq(20066,nobody)
init(1)───dnsmasq(20262,lxc-dnsmasq)

The lxc-net restart is discussed here:
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1043588

Answered By: Håkon A. Hjortland

Just run this command:

sudo /etc/init.d/dnsmasq restart
Answered By: Parambir Singh

Simply restarting network manager does not work for me (as in new DNS setup is not used).

$ ps aux | grep dns
libvirt+  2217  0.0  0.0  28200   668 ?        S    May30   0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf
nobody   17685  0.1  0.0  32604  1560 ?        S    14:39   0:01 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/sendsigs.omit.d/network-manager.dnsmasq.pid --listen-address=127.0.1.1 --conf-file=/var/run/NetworkManager/dnsmasq.conf --cache-size=0 --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

Then so in here you need to run :
sudo kill 17685

Then finally
sudo service network-manager restart

This applies new the dnsmasq settings as well.

Answered By: KouDy
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.