brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dnsmasq --test checks the config and exits without starting

Network and access
~/tips/tip-dns-dnsmasq-test

dnsmasq --test

Syntax-checks the dnsmasq configuration and exits without starting the server.

Many routers, Pi-hole installs and small servers run dnsmasq for DNS and DHCP. Restarting it with a broken config can leave a network without DNS for a while, and a dry check avoids that.

The flag is in the dnsmasq man page:

dnsmasq --test

It reads and syntax-checks the configuration files, exits with code 0 if everything is fine or a non-zero code otherwise, and does not start dnsmasq. Without other options it checks the default configuration, normally /etc/dnsmasq.conf. To check a different file, add --conf-file, or -C for short:

dnsmasq --test --conf-file=/etc/dnsmasq.d/my-test.conf

The man page says that option stops dnsmasq from reading the default configuration file, so you test exactly that file and nothing else. When your real setup spreads over a directory of snippets, pass the same options your service uses.

A restart that depends on the result looks like this:

dnsmasq --test && sudo systemctl restart dnsmasq

If the check fails, the command exits with a non-zero code and the restart never happens.

The caveat is the word syntax. A rule that is valid but wrong, like an address= line that points a name at the wrong IP, passes happily. Software that bundles its own dnsmasq may call it by another binary name or start it with extra options, so make sure you test the same program and the same options as the one that runs.

Further reading: dnsmasq manual

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link