named-checkzone

The named-checkzone command is a utility in the BIND (Berkeley Internet Name Domain) suite used to check the syntax and integrity of DNS zone files. It validates the zone file, ensuring that it complies with DNS standards and is free from errors.

Basic Syntax

The basic syntax for named-checkzone is:

named-checkzone [options] zone-name zone-file
  • zone-name: The name of the DNS zone.

  • zone-file: The path to the zone file to be checked.

Common Options

  • -i style: Sets the integrity checking level. The options are full, none, and warn. The default is full.

  • -k mode: Sets the "check-names" mode. Options are warn, fail, and ignore. The default is the value specified in named.conf or fail if not specified.

  • -j: Treat the zone file as a journal file.

  • -J: Output the zone file in journal format.

  • -n mode: Sets the "check-names" mode for the owner names of records. Options are warn, fail, and ignore.

  • -q: Quiet mode. Only errors are printed.

  • -v: Prints the version of named-checkzone and exits.

  • -D: Dumps the zone file in canonical format.

  • -o file: Outputs the parsed zone file to the specified file.

  • -k mode: Sets the "check-names" mode for owner names of records. Options are warn, fail, and ignore.

  • -M or -m: Check if the zone file should have MX records.

Example Usage

Basic Zone File Check

To check a zone file example.com.zone for the zone example.com, use the following command:

named-checkzone example.com /etc/bind/zones/example.com.zone

Checking a Zone File with Specific Options

To check a zone file and set specific integrity checking and "check-names" modes:

named-checkzone -i full -k warn example.com /etc/bind/zones/example.com.zone

Quiet Mode

To check a zone file and only print errors:

named-checkzone -q example.com /etc/bind/zones/example.com.zone

Output to a File

To check a zone file and output the parsed zone file to another file:

named-checkzone -o /etc/bind/zones/example.com.parsed example.com /etc/bind/zones/example.com.zone

Practical Scenario

Suppose you have a DNS zone file for example.com located at /etc/bind/zones/example.com.zone, and you want to validate it:

named-checkzone example.com /etc/bind/zones/example.com.zone

If the zone file is valid, you will see output similar to:

zone example.com/IN: loaded serial 2021071501
OK

If there are errors, they will be printed to the console, helping you identify and fix them.

Benefits of Using named-checkzone

  • Error Detection: Helps identify and fix syntax errors and misconfigurations in zone files before they are loaded by the DNS server.

  • Standards Compliance: Ensures that the zone file complies with DNS standards and best practices.

  • Time-Saving: Saves time by catching errors early in the configuration process, reducing troubleshooting and downtime.

  • Validation: Provides a way to validate changes to zone files before deploying them, ensuring that updates are correct and will not cause issues.

Conclusion

The named-checkzone tool is an essential utility for DNS administrators using BIND. It helps ensure the integrity and correctness of DNS zone files by performing thorough syntax and compliance checks. By understanding and utilizing its various options, administrators can effectively manage and validate their DNS zones, ensuring smooth and error-free DNS operations.

Last updated