what's wrong with my Ubuntu 11.10 bind9 configuration?

John Bowlinger asked:

I’ve followed several tutorials on installing your own nameservers and I’m pretty much at my wit’s end, because I cannot get them to resolve. Note, the actual domain and ip address has been changed for privacy to example.com and My named.conf.local file:

zone "example.com" {
    type master;
    file "/var/cache/bind/example.com.db";

zone "0.168.192.in_addr.arpa" {
  type master;
  file "/var/cache/bind/192.168.0.db";

My named.conf.options file:

options {
    forwarders {;

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };

My resolv.conf file:

search example.com.

My Forward DNS file:

ORIGIN example.com.
$TTL  86400
@    IN    SOA   ns1.example.com.    root.example.com. (
    2012083101  ; Serial
    604800  ; Refresh
    86400  ; Retry
    2419200  ; Expire
    3600 )  ; Negative Cache TTL

example.com. NS    ns1.example.com.
example.com. NS    ns2.example.com.
example.com. MX    10 mail.example.com.

@        IN  A
ns1.example.com       IN  A
ns2.example.com       IN  A
mail     IN  A
server1  IN  A

gateway    IN CNAME ns1.example.com.
headoffice IN CNAME server1.example.com.
smtp       IN CNAME mail.example.com.
pop        IN CNAME mail.example.com.
imap       IN CNAME mail.example.com.
www        IN CNAME server1.example.com.
sql        IN CNAME server1.example.com.

And my reverse DNS:

$ORIGIN 0.168.192.in-addr.arpa.
$TTL  86400
@  IN  SOA  ns1.example.com.  root.example.com. (
    2009013101  ; Serial
    604800  ; Refresh
    86400  ; Retry
    2419200  ; Expire
    3600 )  ; Negative Cache TTL

1    PTR mail.example.com.
1    PTR server1.example.com.
2    PTR ns1.example.com.

Yet, when I restart bind9 and do:

host ns1.example.com localhost

I get:

Using domain server:
Name: localhost

Host ns1.example.com.example.com not found: 2(SERVFAIL)

Similarly, for:

host localhost

I get:

;; connection timed out; no servers could be reached

Anybody know what’s going on? Btw, my domain name “www.example.com” that I’ve used in this question is being forwarded to my ISP’s nameservers. Would that affect my bind9 configuration? I want to learn how to do set up nameservers on my own for learning, so that is why I’m going through all this trouble.

My answer:

The problematic entries are here:

ns1.example.com       IN  A
ns2.example.com       IN  A

Your domain gets added to the end of each of these, if you haven’t terminated them with a period. To get it working, change them to:

ns1       IN  A
ns2       IN  A

You also need to make the change @Zoredache gave to fix your reverse DNS (but you wouldn’t have discovered that problem until later…)

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.