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: named-checkzone catches zone file mistakes before the name server loads them

Linux
~/tips/tip-dns-named-checkzone

named-checkzone example.com /etc/bind/db.example.com

Validates a BIND zone file the way the name server would, before you reload it.

If you run your own authoritative DNS with BIND, one missing dot or a bad record in a zone file means the zone does not load. Checking before a reload is cheap.

The tool takes a zone name and a file:

named-checkzone example.com /etc/bind/db.example.com

The BIND manual says it checks the syntax and integrity of a zone file and performs the same checks as named does when loading a zone. It returns an exit status of 1 if errors were detected and 0 otherwise.

By default the integrity checks run after the load. The -i option sets the mode, and the default is full. In that mode it checks that MX records, SRV records and delegation NS records refer to names that have an A or AAAA record, and that glue records match what the child advertises. -i none turns these checks off. The -q option gives quiet mode, where only the exit code tells you the result.

A safe reload then looks like this. The rndc reload command takes an optional zone and reloads only that zone:

named-checkzone example.com /etc/bind/db.example.com && sudo rndc reload example.com

The -D option dumps the zone in canonical format, which shows the file as BIND read it.

The caveat: the checker does not know what you meant to change. Remember to raise the SOA serial when you edit a zone, because secondary servers only pick up a change when the serial goes up, and a file with an unchanged serial is not an error to the tool.

Further reading: BIND 9 manual pages (named-checkzone)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link