named-checkzone(8)
Check the syntax and validity of a DNS zone file.
Synopsis
named-checkzone [OPTION]... ZONENAME FILENAMEDescription
named-checkzone is a utility that reads a DNS zone file and checks it for syntax errors and other problems. It verifies that the zone data is valid according to DNS standards and BIND zone file format rules.
The command takes a zone name and a zone file path, then reports any errors found. It does not require a running BIND nameserver and is useful for validating zone files before loading them into production.
Common options
| Flag | What it does |
|---|---|
-d | Enable debug output; useful for diagnosing parsing issues |
-f (text|raw) | Specify zone file format; 'text' is the default, 'raw' is binary |
-F (full|relative) | Set output format for filenames; 'full' is default absolute path |
-j | Read journal file if one exists; checks both zone and journal |
-q | Quiet mode; suppress normal output, exit code indicates success/failure |
-v | Verbose output; print zone contents and detailed information |
-w directory | Specify working directory for $INCLUDE and relative paths |
-k (fail|warn|ignore) | Control handling of DNSSEC keys; 'warn' is default |
-n (ignore|warn|fail) | Set behavior for non-terminal wildcards; 'warn' is default |
-o output-file | Write zone contents in text format to output file |
-D | Dump parsed zone contents to stdout in canonical form |
Examples
Check the zone file for example.com; shows errors if any exist
named-checkzone example.com /etc/bind/zones/db.example.comCheck zone file silently; only report success/failure via exit code
named-checkzone -q example.com /etc/bind/zones/db.example.com && echo 'Zone OK'Verify zone and display verbose output showing first 20 records
named-checkzone -v example.com /etc/bind/zones/db.example.com | head -20Check zone and write canonical output to /tmp/output.txt for inspection
named-checkzone -o /tmp/output.txt example.com /etc/bind/zones/db.example.comEnable debug output and filter for error messages only
named-checkzone -d example.com /etc/bind/zones/db.example.com 2>&1 | grep -i errorCheck zone using /var/cache/bind as working directory for relative paths
named-checkzone -w /var/cache/bind example.com db.example.comCheck multiple zone files in a loop and report any errors
for zone in example.com test.local; do named-checkzone $zone /etc/bind/zones/db.$zone || echo "Error in $zone"; done