Ubuntu: DNS server with Bind9: can't resolve DNS records in forward and reverse zone files



Question:

Hello everyone :) I have tried to set up my own DNS server with bind9, but although I have tried several tutorials, I still get the same error. Starting bind9 works fine but when I use nslookup or dig against host1 (which exists in the forward zone file) it never manages to resolve the IP address. I have the same problem with the reverse zone file, using the IP address as the argument instead of host1. If I instead lookup, for example, microsoft.com I will get an answer.

Example:

nslookup host1.dirks.crtn  ;; Got SERVFAIL reply from 192.168.56.2, trying next server  ;; Got SERVFAIL reply from 192.168.56.2, trying next server  server 127.0.0.1  address 127.0.0.1#53    ** server can't fint host1.dirks.crtn.dirks.crtn: SERVFAIL  

I also tried host1:

nslookup host1  ;; Got SERVFAIL reply from 192.168.56.2, trying next server   server: 192.168.56.2  address 192.168.56.2#53    ** server can't find host1: NXDOMAIN  

With microsoft.com:

nslookup microsoft.com  server: 192.168.56.2  address: 192.168.56.2#53    Non-authoritative answer:  name: microsoft.com  address: 134.170.188.221  name: microsoft.com  address 134.170.185.46  

My current files:

File /etc/bind/named.conf.options:

options {  directory "/var/cache/bind";  recursion yes;      forwarders {    8.8.8.8;    8.8.4.4;    };    allow-query {    192.168.56.0/24;    };    allow-transfer {    192.168.56.0/24;    };  };  

File /etc/bind/named.conf.local:

zone "dirks.crtn" {  type master;  file "etc/bind/zones/dirks.crtn.db";  };    zone "56.168.192.in-addr.arpa" {  type master;  file "etc/bind/zones/rev.56.168.192.in-addr.arpa";  };  

Forward Zone File - /etc/bind/zones/dirks.crtn.db:

$ORIGIN .  $TTL 907200          ; 1 week 3 days 12 hours    dirks.crtn           IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (         1263527838    ; serial         10800         ; refresh         3600          ; retry (1 hour)         604800        ; expire (1 week)         38400         ; minimum (10 hours 40 minutes)  )  ; name server - NS records          NS   filtjener.dirks.crtn.  ; name server - A records  filtjener.dirks.crtn.      A    192.168.56.2    $ORIGIN dirks.crtn.  host1   A   192.168.56.21  host2   A   192.168.56.22  host3   A   192.168.56.23  

Reverse zone file - /etc/bind/zones/rev.56.168.192.in-addr.arpa:

$TTL 907200     ; 1 week 3 days 12 hours    @ IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (       1263187356    ; serial       10800         ; refresh (3 hours)       3600          ; retry (1 hour)       60400         ; expire (1 week)       38400         ; minimum (10 hours 40 minutes)  )             NS filtjener.dirks.crtn.  ; PTR records  21      PTR      host1.dirks.crtn.  22      PTR      host2.dirks.crtn.  23      PTR      host3.dirks.crtn.  

File /etc/resolvconf/resolv.conf.d/head:

search dirks.crtn  nameserver 192.168.56.2  

File /etc/network/interfaces:

auto lo  iface eth1 inet static  address 192.168.56.2  netmask 255.255.255.0  

I checked the files:

sudo named-checkconf    sudo named-chekckzone rev.56.168.192.in-addr.arpa /etc/bind/zones/rev.56.168.192.in-addr.arpa  zone rev.56.168.192.in-addr.arpa/IN: loaded serial 1263187356  OK    sudo named-checkzone dirks.crtn /etc/bind/zones/dirks.crtn.db  zone dirks.crtn/IN: loaded serial 1263527838  OK  

and have restarted bind9:

sudo /etc/init.d/bind9 restart  * Stopping domain name service... bind9 [ok]  waiting for pid 2765 to die    * starting domain name service... bind9 [ok]  

I'm using VirtualBox and since I haven't managed to copy and paste from VirtualBox, it might be small errors in the files.

Does anyone know what I might be doing wrong here? :) I appreciate any help :)


Solution:1

So forwarding is working fine. Things in your configuration files do look a little odd to me. Note that I have never been able to make things work with $ORIGIN. I'm sure that somehow it does work, just not for me.

For dirks.crtn.db try:

$TTL 38400  @      IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (         1263527838    ; serial         10800         ; refresh         3600          ; retry         604800        ; expire         38400 )       ; Negative Cache TTL         IN  A  192.168.56.2  ;  ; name server - NS records  @      IN  NS   filtjener.dirks.crtn.  ; name server - A records  filtjener IN   A    192.168.56.2    host1   IN A   192.168.56.21  host2   IN A   192.168.56.22  host3   IN A   192.168.56.23  

For rev.56.168.192.in-addr.arpa try:

$TTL 38400    @ IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (       1263187356    ; serial       38400         ; refresh       3600          ; retry 1 hour       60400         ; expire 1 week       38400 )       ; negative cache TTL  ;  @    IN   NS    filtjener.dirks.crtn.  2    IN   PTR   filtjener.dirks.crtn.  21   IN   PTR   host1.dirks.crtn.  22   IN   PTR   host2.dirks.crtn.  23   IN   PTR   host3.dirks.crtn.  

You do not need to use sudo with named-checkzone and note that for reverse zone checking the command is:

named-checkzone 56.168.192.in-addr.arpa rev.56.168.192.in-addr.arpa  

reference


Solution:2

So I finally found the answer to my own problem in /etc/bind/named.conf.local i forgot to add "/" in front of "etc".

my way:

zone "dirks.crtn" {  type master;  file "etc/bind/zones/dirks.crtn.db";  };  

correct way:

zone "dirks.crtn" {  type master;  file "/etc/bind/zones/dirks.crtn.db";  };  

I feel kinda stupid, but at least I am able to resolve addresses and hostnames.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »