Network
The named-checkzone command
Validates a DNS zone file before loading it: syntax, SOA and NS records.
Most useful options
-c claseDNS class of the zone. If you do not give it, IN is used-f formatoInput file format: text (the default) or raw, BIND's binary format-i modoIntegrity checks: full, full-sibling, local, local-sibling or none. With local, MX, SRV and NS are only checked when they point to names in the zone itself-o ficheroDumps the loaded zone to that file, in the format set with -F. Only if loading succeeds-qQuiet: prints no OK and no loader messages. The exit status still reports the resultCopy-ready examples
$ named-checkzone aula.local /etc/bind/db.aula.localvalidates the classroom zone. If there are no errors, it reports the loaded serial number and prints OK.Example output
zone aula.local/IN: loaded serial 2 OK
$ named-checkzone -q aula.local /etc/bind/db.aula.local; echo $?only the exit status: 0 if the zone is correct, 1 if it is not.Example output
0
$ cat /etc/bind/db.aula.local | named-checkzone aula.local -reads the zone from standard input, given as a dash.$ named-checkzone -i local aula.local /etc/bind/db.aula.localchecks MX, SRV and NS only when they point to names in the zone itself, useful if external hosts do not resolve yet.$ named-checkzone -o /tmp/aula.zona aula.local /etc/bind/db.aula.localvalidates and saves the loaded zone to another file.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| named-checkzone: illegal option -- z | You used an option that does not exist. It then also prints «invalid argument» and the usage help. | Check the options with named-checkzone -h, which exits with status 0. |
| zone aula.local/IN: has no NS records | The zone has no NS record at its origin. It is a warning from the check. | Add at least one NS record at the origin, for example: @ IN NS ns1.aula.local. |
| zone aula.local/IN: has 0 SOA records | The file has no SOA record. Without it the zone does not load and the program exits with status 1. | Add a single SOA record at the origin of the zone. |
Typical mistakes
- named-checkzone checks the file, not the server: even if the zone passes, BIND can reject the configuration if another part fails.
- The first argument is the zone name and the second the file. The order matters.
- It exits with 1 on errors and 0 otherwise. In a script check the status with && or with if.
Differences from similar commands
- named-checkconf: checks the syntax of named.conf and its included files. named-checkzone checks the contents of one zone.
named-compilezone: is the same tool in compile mode: it writes the zone to an output file, and -o is required.
Related commands
FAQ
How does it differ from named-checkconf?
named-checkconf checks named.conf and its included files. named-checkzone checks one specific zone: its records, SOA and NS.
What does the final OK mean?
That the zone loaded without errors. Warnings and the serial number may come before it. With -q it prints nothing, and exit status 0 means the same.
Do I need sudo to check a zone?
Normally not. Checking only reads the zone file, so being able to read it is enough. Installing it on the server is a separate task.
Can I check a zone before publishing it?
Yes. named-checkzone only reads the file: it does not need named running or the zone installed.
More Network commands
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