Jump to content

How to find a syntax error in a named.conf file

+ 1
  cricketliu's Photo
Posted Sep 15 2009 11:43 AM

If you suspect you have a syntax error in named.conf, check the name server's syslog output to see if named logged any error messages the last time you started or reloaded it. Look for a message like this, indicating the last time you started the name server:

Jun 25 15:42:43 ns1 named[53702]: starting BIND 9.2.1

Jun 25 15:42:43 ns1 named[53702]: using 1 CPU

Jun 25 15:42:43 ns1 named[53702]: loading configuration from '/etc/named.conf'

If you reloaded the name server, the message will look like this:

Jun 25 15:44:25 ns1 named[53702]: loading configuration from '/etc/named.conf'

If you can't find the last time the name server was started or reloaded, you can always reload it again with rndc reload (BIND 9), then check named's syslog output immediately. Or you can start a BIND 9 name server with the -g option, which tells named to run in the foreground and send all error messages to standard error. For example:

$ named -g                          

Jun 25 15:53:37.745 starting BIND 9.2.1 -g

Jun 25 15:53:37.745 using 1 CPU

Jun 25 15:53:37.750 loading configuration from '/etc/named.conf'

Jun 25 15:53:37.750 /etc/named.conf:7: missing ';' before 'acl'

Jun 25 15:53:37.754 loading configuration: failure

Jun 25 15:53:37.754 exiting (due to fatal error)

This makes the error fairly obvious: there's a missing semicolon on line 7 of named.conf, before the keyword acl.

You can also check a named.conf file without running named, by using the BIND 9 named-checkconf program. named-checkconf uses the same routines that named would to check the named.conf file. For example, running named-checkconf on the named.conf file that produced the output above produces very similar output:

$ named-checkconf

/etc/named.conf:7: missing ';' before 'acl'
Cover of DNS & Bind Cookbook
Learn more about this topic from DNS & Bind Cookbook. 

The DNS & BIND Cookbook presents solutions to the many problems faced by network administrators responsible for a name server. This title is an indispensable companion to DNS & BIND, 4th Edition, the definitive guide to the critical task of name server administration. The cookbook contains dozens of code recipes showing solutions to everyday problems, ranging from simple questions, like, "How do I get BIND?" to more advanced topics like providing name service for IPv6 addresses.

Learn More Read Now on Safari


Tags:
0 Subscribe


0 Replies