Dnsmasq not starting

Please follow the below template, it will help us to help you!

Expected Behaviour:

For pihole to run, dnsmasq to run

Actual Behaviour:

dnsmasq not starting and pihole not working

Debug Token:

f0mq9746zt

What is the output from sudo systemctl status --full --no-pager dnsmasq.service

Your debug token is: jupsbv2o91

I'm having the same issue....dnsmasq not starting.
I had just done typical apt-get update && apt-get upgrade -y
No issues.
Then did update the kernal; reboot. Then noticed DNS was not starting.
Per the FAQ, I uninstalled dnsmasq, and then re-installed dnsmasq. Same failure: DNS not starting
Here is the output of the systemctl command:

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
Drop-In: /run/systemd/generator/dnsmasq.service.d
└─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
Active: failed (Result: exit-code) since Mon 2018-06-25 22:33:11 PDT; 2min 21s ago

Jun 25 22:33:10 pidns dnsmasq[2070]: dnsmasq: syntax check OK.
Jun 25 22:33:11 pidns dnsmasq[2076]: dnsmasq: junk found in command line
Jun 25 22:33:11 pidns systemd[1]: dnsmasq.service: control process exited, code=exited status=1
Jun 25 22:33:11 pidns systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Jun 25 22:33:11 pidns systemd[1]: Unit dnsmasq.service entered failed state.

and
pi@pidns:~ $ uname -a
Linux pidns 4.14.50+ #1122 Tue Jun 19 12:21:21 BST 2018 armv6l GNU/Linux

Systemd is reporting that the command line to execute dnsmasq is invalid. What does sudo cat /lib/systemd/system/dnsmasq.service show?

Thanks for the help.
Here is the dsnmasq.service output:

  $ sudo cat /lib/systemd/system/dnsmasq.service
[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server

[Service]
Type=forking
PIDFile=/var/run/dnsmasq/dnsmasq.pid

# Test the config file and refuse starting if it is not valid.
ExecStartPre=/usr/sbin/dnsmasq --test

# We run dnsmasq via the /etc/init.d/dnsmasq script which acts as a
# wrapper picking up extra configuration files and then execs dnsmasq
# itself, when called with the "systemd-exec" function.
ExecStart=/etc/init.d/dnsmasq systemd-exec

# The systemd-*-resolvconf functions configure (and deconfigure)
# resolvconf to work with the dnsmasq DNS server. They're called liek
# this to get correct error handling (ie don't start-resolvconf if the
# dnsmasq daemon fails to start.
ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf


ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

Try manually running the daemon sudo /etc/init.d/dnsmasq systemd-exec and see if there are any errors generated.

So basically the same thing:

sudo /etc/init.d/dnsmasq systemd-exec

dnsmasq: junk found in command line

Looks like it's a bug in dnsmasq https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860064 Can you upgrade to Raspbian Stretch with the correct supported version of dnsmasq?

Actually, reading through that bug report it looks like Debian has broken dnsmasq so an upgrade to Stretch will not help in this case. Investigating.

Ok. I'll hold.
There was another, older Help Post, where the OP fixed his DNSMASQ by upgrading to Raspbian Stretch.
Here is the other Post:

I was going to do that upgrade, but I thought I'd wait to see what happens on this thread.

Currently dnsmasq is at version 2.76 on my Pi-Hole server:

dnsmasq -v
Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley

That looks to be a version that is affected. What does apt-cache policy dnsmasq show as the package version?

sudo apt-cache policy dnsmasq
dnsmasq:
Installed: 2.72-3+deb8u2
Candidate: 2.72-3+deb8u2
Version table:
*** 2.72-3+deb8u2 0
500 Index of /raspbian jessie/main armhf Packages
100 /var/lib/dpkg/status

I ran into the same problem today when restarting pihole while trying to switch to other outbound dns. The recentrly updated packages on my raspi also seem harmless.

When trying to manually start dnsmasq via "sudo bash -x /etc/init.d/dnsmasq systemd-exec" (to get the variables expanded) it creates this starting command which doesn't suprise me that dnsmasq doesn't like it.

+ exec /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service . 172800 IN DS 19036,8,2,49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5 . 172800 IN DS 20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d

Those expanded parameter is created by

ROOT_DS="/usr/share/dns/root.ds"

if [ -f $ROOT_DS ]; then
DNSMASQ_OPTS="$DNSMASQ_OPTS sed -e s/". IN DS "/--trust-anchor=.,/ -e s/" "/,/g $ROOT_DS | tr '\n' ' '"
fi

Edit:
Found the dnsmasq Bugreport for this
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=858506

The solution in it is

If I use the line in file /etc/init.d/dnsmasq

DNSMASQ_OPTS="$DNSMASQ_OPTS sed -e s/'.*IN[[:space:]]DS[[:space:]]'/--trust-anchor=.,/ -e s/'[[:space:]]'/,/g $ROOT_DS | tr '\n' ' '"

everything is OK again.

After that change my local dnsmasq started fine again

1 Like

Calisto42,
Thank you for the info and reference to the bug report.
So I manually typed in the changes you pasted into your reply above and found one slight change from what got pasted and what the bugreport solution provided. I think the Discourse editor is gobbling up back quotes (aka "back ticks". In the bugreport answer the entire sed command has single back-tick just before the sed and then another back tick at the end just before that final double-quote.
Let me see if I can "fool" the Discourse editor to include that back tick around the sed command:

 DNSMASQ_OPTS="$DNSMASQ_OPTS `sed -e s/'.*IN[[:space:]]DS[[:space:]]'/--trust-anchor=.,/ -e s/'[[:space:]]'/,/g $ROOT_DS | tr '\n' ' '`" 

That looks better.
This line fixed my DNSMASQ starting up error.

Thank you all for your help.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.