Ubuntu – Dnsmasq unrecognized command

dnsdnsmasqnetwork-managernetworking

I'm attempting to run a script which calls service dnsmasq restart

service dnsmasq restart
dnsmasq: unrecognized service

No matter what I call for dnsmasq, it gives me the "unrecognized service" error.

Also if I type dnsmasq restart I get

dnsmasq restart
dnsmasq: junk found in command line

I have tried autoremoving and reinstalling dnsmasq. I've googled both responses, and not finding any fixes. Can anyone help?

Thanks!

Best Answer

The error is a problem with the package dns-root-data. DNSmasq shouldn't require it, but it is requiring it. Follow these steps:

sudo apt-get purge dnsmasq
sudo apt-get autoremove
sudo apt-get install dnsmasq

Don't forget to re-insert your configuration (if any) into /etc/dnsmasq.conf

Reference


If that didn't work, try this (works at least on Debian 9 and Raspian)

sudo nano /etc/init.d/dnsmasq

Where it reads

if [ -f $ROOT_DS ]; then

Comment out the next line (add # to the beginning of the line) and put this one below it

`DNSMASQ_OPTS="$DNSMASQ_OPTS `mawk -- '{ printf " --trust-anchor=.,%d,%d,%d,%s", $5, $6, $7, $8 }' $ROOT_DS`"`

The structure of /usr/share/dns/root.ds was changed. The fields used to be separated only by spaces, now they are separated by tabs (\t)

Reference

Related Question