Verifying a DNS configuration is a critical step to ensure you don't have syntax errors that could prevent the service from starting. BIND provides two excellent built-in tools for this:
1. Check the Main Configuration Syntax
Before restarting the service, you should check if named.conf.local has any typos or missing semicolons. Run:
sudo named-checkconf
- If it returns nothing: Everything is perfect.
- If there is an error: It will tell you the exact line number where the problem is.
2. Check the Zone Files
Even if the configuration is correct, the individual "database" files might have errors (like a missing dot at the end of a domain). You can verify them specifically:
For the Forward Zone:
sudo named-checkzone mylocaldomain.net /etc/bind/db.mylocaldomain.net
For the Reverse Zone:
First, you'll need the name of your reverse IP variable if you want to be precise, but you can also just check the file directly:
# Replace <REV_IP> with the actual filename created in your /etc/bind/ folder
# Example: sudo named-checkzone 0.18.172.in-addr.arpa /etc/bind/db.172.18.0
ls /etc/bind/db.* # Run this to see your filename first
- Result: You should see an output ending in
OK.
3. Check After Restarting
Once you feel confident and restart the service (sudo systemctl restart bind9), check the system logs to see if BIND actually loaded the zones:
sudo tail -n 20 /var/log/syslog | grep named
Look for lines that say:
all zones loadedrunningzone mylocaldomain.net/IN: loaded serial ...
Summary:
Use named-checkconf for the settings and named-checkzone for the data records. If both say they are okay, your DNS server is ready to work!