A zone edit breaks the entire named process. Restarting fails. The customer’s site goes down, and so does every other site on the same nameserver because named refuses to start with an invalid zone in its config. The fix is two minutes (revert the change, reload), but the discovery and rollback take longer. The whole incident could be avoided with named-checkzone as a pre-commit step.
What’s happening
BIND’s named-checkzone parses a zone file with the same logic named itself uses at load time. If named-checkzone rejects the file, named will reject it too. It catches:
- Syntax errors (missing trailing dots, malformed record values, unbalanced quotes).
- Records that violate spec (a CNAME at the apex, a CNAME coexisting with other records at the same name, multiple SOA records).
- SOA values that are out of range (refresh, retry, expire mis-ordered).
- TXT strings that exceed the 255-byte limit (with newer BIND).
cPanel’s Zone Editor validates most of these in the UI, but direct file edits and whmapi1 calls don’t run named-checkzone automatically — they hand the file to named and hope.
How to verify
Run named-checkzone against a zone file:
named-checkzone example.com /var/named/example.com.db
Output is either OK or a specific error with line number. Common errors and what they mean:
unknown RR type 'XYZ'— record type misspelled, or BIND too old for this type.not a valid number— TTL or numeric field is malformed.CNAME and other data— CNAME coexists with another record at the same name.loaded serial XXXXXXafterOK— the zone passed; this is the serialnamedwill use.
For batch validation:
for zone in /var/named/*.db; do
result=$(named-checkzone $(basename $zone .db) $zone 2>&1)
if echo "$result" | grep -q OK; then
echo "OK: $zone"
else
echo "FAIL: $zone — $result"
fi
done
For checking named.conf as a whole:
named-checkconf
named-checkconf -p
-p prints the parsed config; useful for confirming includes are resolving.
What to do
- Run
named-checkzoneon every zone after any direct edit. Make it part of the script that does the edit — no edit is complete until the validation passes. - Run
named-checkconfbefore reloadingnamed. A bad config rejects all zones, not just the broken one. - For cluster operations, run validation on the peer before pushing:
ssh peer "named-checkzone example.com /var/named/example.com.db" || echo "Peer rejects this zone"
- Set up a pre-commit hook if you store zone files in version control. The hook should run
named-checkzoneon every changed file and reject the commit if any fail. - In a Zone Editor UI workflow, the UI does its own validation but doesn’t show the exact
named-checkzoneoutput. After a bulk Zone Editor change, run a manual check to confirm nothing slipped through. - When a zone genuinely fails, the rollback is to restore the previous zone file from backup (
/var/named/example.com.db.YYYYMMDD-HHMM.bakif you made one) andrndc reload example.com. If you didn’t make a backup, the cluster peer might have the previous good version — pull it back from there.
A common subtle failure: a zone passes named-checkzone on the master but fails on a slave because the BIND versions differ. Newer BIND is stricter about TXT segmentation and DNSSEC algorithms. If the master runs BIND 9.16 and the slave runs BIND 9.20, the same file may load on one and not the other. Keep BIND versions consistent across the cluster.
Stack Harbor includes named-checkzone validation in every DNS workflow as part of managed cPanel operations.