Network

The named-checkconf command

Checks the syntax of the BIND named.conf file and of the files it includes.

Syntax

named-checkconf [/etc/bind/named.conf]Try it in the terminal →

Most useful options

-zBesides the syntax, test-loads every zone of type primary.
-lLists the configured zones, with name, class, view and type.
-pPrints the configuration in canonical form, if there are no errors.
-xOnly with -p: replaces the shared secrets with question marks.
-t directorioChroots to that directory before processing the include directives.
-jWhen loading a zone file, also reads its journal if it exists.
-vPrints the named-checkconf version and exits.

Copy-ready examples

$ named-checkconfvalidates the default file. If there are no errors, the exit code is 0.
$ named-checkconf /etc/bind/named.confvalidates a specific file, given its path.
$ named-checkconf -z /etc/bind/named.confbesides the syntax, test-loads each primary zone.
$ named-checkconf -l /etc/bind/named.conflists the configured zones, with their type.
$ named-checkconf -p -x /etc/bind/named.conf > named-canonico.confsaves the configuration without secrets, ready to share in a report.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
/etc/bind/named.conf:12: missing ';' before 'zone'A semicolon is missing before that word. The mistake is usually at the end of the previous line or block.Add the missing ; and run named-checkconf again.

Typical mistakes

  • named-checkconf does not check semantics. To validate one zone file, use named-checkzone.
  • The exit code is 1 if there are errors and 0 if not. In a script, check $? instead of reading the output.
  • Without a file, it uses the path BIND was built with: /etc/bind/named.conf on Debian and Ubuntu, and /etc/named.conf on other distributions.

FAQ

What does named-checkconf check?

The syntax of named.conf and of the files it includes. It does not check semantics. With -z, it also test-loads the primary zones.

How do I use it in a script?

Run it and check the exit code: 0 if everything is fine, 1 if there were errors. Use && or if to decide what comes next.

How does it differ from named-checkzone?

named-checkconf validates named.conf and its includes. named-checkzone validates a single zone file.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course