Skip to content

Instantly share code, notes, and snippets.

@rwp0
Forked from shuhaowu/debug-dnsmasq.sh
Last active November 26, 2022 18:50
Show Gist options
  • Save rwp0/30497c37bbe1c6cb2ed41cc38aa6aa55 to your computer and use it in GitHub Desktop.
Save rwp0/30497c37bbe1c6cb2ed41cc38aa6aa55 to your computer and use it in GitHub Desktop.
Debug DNSmasq by Llogging its Queries

In /etc/NetworkManager/dnsmasq.d/log.dnsmasq.conf:

log-queries  = extra
log-facility = /var/log/dnsmasq.log
systemctl NetworkManager restart
tail -f /var/log/syslog | ccze -A

-q, --log-queries Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. If the argument "extra" is supplied, ie --log-queries=extra then the log has extra information at the start of each line. This consists of a serial number which ties together the log lines associated with an individual query, and the IP address of the requestor.

-8, --log-facility= Set the facility to which dnsmasq will send syslog entries, this defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If the facility given contains at least one '/' character, it is taken to be a filename, and dnsmasq logs to the given file, instead of syslog. If the facility is '-' then dnsmasq logs to stderr. (Errors whilst reading configuration will still go to syslog, but all output from a successful startup, and all output whilst running, will go exclusively to the file.) When logging to a file, dnsmasq will close and reopen the file when it receives SIGUSR2. This allows the log file to be rotated without stopping dnsmasq.

https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

https://wiki.archlinux.org/title/dnsmasq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment