named-checkconf

The named-checkconf utility is a command-line tool provided by BIND (Berkeley Internet Name Domain), the widely used DNS server software. This tool is used to check the syntax and validity of the named.conf configuration file and any files it includes. Running named-checkconf helps ensure that your DNS server's configuration is free from errors before starting or restarting the BIND service.

Usage

named-checkconf [options] [filename]
  • options: Various command-line options to control the behavior of named-checkconf.

  • filename: The configuration file to be checked. If not specified, it defaults to /etc/named.conf or /etc/bind/named.conf depending on the distribution.

Common Options

  • -t directory: Chroot to the specified directory. Useful for checking configurations in chroot environments.

  • -z: Perform a test load of all master zones found in named.conf.

  • -p: Print the parsed configuration file and exit.

  • -v: Print the version of named-checkconf.

Examples

  1. Basic Syntax Check

    To check the default configuration file:

    named-checkconf
  2. Check a Specific Configuration File

    If your configuration file is located at a non-default path:

    named-checkconf /path/to/your/named.conf
  3. Check Configuration in a Chroot Environment

    If BIND is running in a chroot environment:

    named-checkconf -t /var/named/chroot
  4. Test Load of All Master Zones

    To verify that all master zone files referenced in the configuration can be loaded correctly:

    named-checkconf -z
  5. Print Parsed Configuration

    To print the parsed version of the configuration file:

    named-checkconf -p

Using named-checkconf in Practice

Suppose you have the following BIND configuration in /etc/named.conf:

options {
    directory "/var/named";
    // more options here
};

zone "example.com" IN {
    type master;
    file "example.com.zone";
    allow-update { none; };
};

zone "1.168.192.in-addr.arpa" IN {
    type master;
    file "192.168.1.zone";
    allow-update { none; };
};

Before starting or restarting BIND, you would run:

named-checkconf /etc/named.conf

If there are no errors, the command will exit silently. If there are syntax errors or other issues, it will print messages indicating the problems, allowing you to correct them before proceeding.

Benefits of Using named-checkconf

  1. Error Detection: Catches syntax errors and misconfigurations before they can cause runtime issues.

  2. Validation: Ensures that included files and zone files are correctly referenced and formatted.

  3. Peace of Mind: Provides confidence that your DNS server will start correctly with the intended configuration.

Conclusion

The named-checkconf utility is an essential tool for managing BIND DNS configurations. Regular use of this tool as part of your configuration management process can help prevent downtime and ensure that your DNS server runs smoothly. Always verify your configuration with named-checkconf before applying any changes to your DNS infrastructure.

Last updated