12

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
  • 9,385
  • 44
  • 120
  • 178

3 Answers3

12

--no-daemon

dnsmasq will print errors to the terminal if you run it directly. i.e. dnsmasq --no-daemon, or with all logging options:

$ dnsmasq --no-daemon --log-queries=extra --log-dhcp --log-debug -C /path/to/dnsmasq.conf

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

--test

dnsmasq --test will do basic syntax checks on the config files. If successful, it should print something like

$ dnsmasq --test
dnsmasq: syntax check OK.

A contrived failure looks like

$ echo 'A-VERY-BAD-OPTION' > /tmp/tmp.conf
$ dnsmasq -C /tmp/tmp.conf --test

dnsmasq: bad option at line 1 of /tmp/tmp.conf

permissions

If you test without sudo then for a good config, dnsmasq should eventually reach the stage where it tries to start listening on port 53, but fails due to permissions.

If you use sudo (or you set port=1024 or higher in the config) then dnsmasq should actually start running, but then you may have to kill the process manually. If you've run with --no-daemon, this is easy to do with Ctrl-C.

mwfearnley
  • 7,889
6

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.
  • 113
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
  • 21