Bind9 name server cannot resolves local domain

binddomain-name-systeminternal-dnsubuntu-14.04

I tried to set up bind DNS in Ubuntu.

I have two machines (VMware):

machine A is client:

IP: 192.168.1.1  (host-only)
hostname: example.com 

machine B is DNS Server:

IP: 192.168.1.2 (host-only)

/etc/bind/named.conf.local:

zone "example.com" {
        type master;
        file "/etc/bind/db.example.com";
};
//reverse zone
zone "1.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.192";
};

/etc/bind/db.example.com:

$TTL    604800
@       IN      SOA     example.com.        root.example.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      example.com.
@       IN      A       192.168.1.1
@       IN      AAAA    ::1

/etc/bind/db.192:

$TTL    604800
@       IN      SOA     1.168.192.in-addr.arpa. root.example.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      example.com.
1       IN      PTR     example.com.

When i use nslookup in client:

nslookup example.com
Server:     192.168.1.2
Address:    192.168.1.2#53

Name:   example.com
Address: 192.168.1.1

nslookup 192.168.1.1
Server:     192.168.1.2
Address:    192.168.1.2#53

** server can't find 1.1.168.192.in-addr.arpa: NXDOMAIN

Can you fix it?

Best Answer

First of all you state in your named.conf.local that your zone is example.com. So B hostname cannot be example.com. It could be some-hostname on example.com like foo.example.com but not example.com since it implies that your zone is com and B's hostname is example which is not consistent with the configuration you provided.

There is an error in/etc/bind/db.example.com.

@       IN      NS      example.com.

This lines is used to specify domain name server. Here you just said :

@(expand to example.com)'s name server is `example.com`

which should be

@       IN     NS      "B's hostname".example.com

Then you specify the A records related to the NS records (i.e your nameserver IP adress) :

hostname       IN      A       192.168.1.1
               IN      AAAA    ::1

But this is still bad configuration. You said before that your nameserver is B with IP 192.168.1.2 right ? So the statement above should be

hostname       IN      A       192.168.1.2

This is the same for the SOA records in db.example.com:

@ IN SOA example.com. root.example.com.

should be :

@       IN      SOA     "B's hostname".example.com.        root.example.com.

SOA records in db.192 should be exactly the same as db.example.com, no needs to write 1.168.192.in-addr.arpa..

Then again your NS and PTR records aren't correct, they should be :

@       IN      NS      "B's hostname".example.com.
2       IN      PTR     "B's hostname".example.com.

I hope I didn't miss something but for last piece of advice Bind9 is packaged with two scripts named-checkzone and named-checkconf. The former can check zone file (i.e db.192 and db.example.com) and the latter can check Bind9 configuration (i.e named.conf.local).

If you are interested in understand better how Bind9 (and dns) you should have a look at Zytrax Pro DNS and Bind which explain very well configuration options with plenty of examples.