Verify dnsmasq configuration

7

1

How to verify dnsmasq's configuration?

dnsmasq used to be able to give verbose info about itself in /var/log/daemon.log, as explained in dnsmasq testing.

However, when I restarted my dnsmasq service, nothing is logged to /var/log/daemon.log:

% echo "    *** DEBUG `date --rfc-3339=seconds` DEBUG *** " >> /var/log/daemon.log

% service dnsmasq restart 
* Restarting DNS forwarder and DHCP server dnsmasq                      [ OK ] 

% tail /var/log/daemon.log
*** DEBUG 2013-11-27 23:04:08-05:00 DEBUG *** 

This is Ubuntu 13.10 Saucy.

xpt

Posted 2013-11-28T04:44:48.583

Reputation: 5 548

Answers

6

dnsmasq will print errors to the terminal if you run it directly.

dnsmasq --test will do basic syntax checks on the config files

dnsmasq on its own will try to start dnsmasq, and gives a line number in the config if it finds any problems there.

Otherwise (if you don't use sudo), it should eventually reach the stage where it tries to create a lease, but fails due to permissions. If you use sudo at this point it should hopefully work, but then you may have to kill the process manually.

mwfearnley

Posted 2013-11-28T04:44:48.583

Reputation: 5 885

5

AFAIK dnsmasq will normally log to the syslog service. By default it uses facility DAEMON.

FWIW: "It works for me" (in Fedora 18 / 19).

If you aren't seeing any messages I'd suggest verifying your syslog configuration. Or, a more emperical approach, try something like "grep -c dnsmasq /var/log/*".

See also the detailed description of logging in the manual page here: http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

There are some other possibilities for logging mentioned there that can effect its behaviour e.g. if facility contains a '/' character.

Are other subsystems (sys-)logging correctly? Can you cause syslog to log a message by using the 'logger' command?

HTH!

Robb.

Robb W.

Posted 2013-11-28T04:44:48.583

Reputation: 93

thanks. It worked for me as well, that was Debian. Thanks for the grep tip, now I found that in Ubuntu 13.10 Saucy dnsmasq logs to syslog instead of daemon.log, even though the man page still says send syslog entries defaults to DAEMON. – xpt – 2013-11-29T02:22:06.063

2

DNSMASQ is one of the common DNS/DHCP cace solution on linux/unix, some good links:

help.ubuntu.com/community/Dnsmasq manpages.ubuntu.com/manpages/lucid/man8/dnsmasq.8.html wiki.debian.org/HowTo/dnsmasq

  1. Verification steps: Turn on the debug logging under /etc/dnsmasq.conf:

log-queries
log-dhcp

  1. Then, restart and watch for logs when you dig hostname:

On debian variants, it dnsmasq logs by default in /var/log/syslog.

mav_2k

Posted 2013-11-28T04:44:48.583

Reputation: 21