$linuxjunkies
>

named-checkzone(8)

Check the syntax and validity of a DNS zone file.

UbuntuDebianFedoraArch

Synopsis

named-checkzone [OPTION]... ZONENAME FILENAME

Description

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

FlagWhat it does
-dEnable 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
-jRead journal file if one exists; checks both zone and journal
-qQuiet mode; suppress normal output, exit code indicates success/failure
-vVerbose output; print zone contents and detailed information
-w directorySpecify 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-fileWrite zone contents in text format to output file
-DDump 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.com

Check 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 -20

Check zone and write canonical output to /tmp/output.txt for inspection

named-checkzone -o /tmp/output.txt example.com /etc/bind/zones/db.example.com

Enable debug output and filter for error messages only

named-checkzone -d example.com /etc/bind/zones/db.example.com 2>&1 | grep -i error

Check zone using /var/cache/bind as working directory for relative paths

named-checkzone -w /var/cache/bind example.com db.example.com

Check 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

Related commands