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
1

4 Answers

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)
5

Just run this command:

sudo /etc/init.d/dnsmasq restart
2

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 finallysudo service network-manager restart

This applies new the dnsmasq settings as well.

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:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like