2

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 :)

  • I've spent days trying to get a similar setup to work. The configs from your questions finally did the trick. Thanks! – jan groth May 5 '16 at 10:46
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

  • Hey, thanks for taking the time to answer :) i modified the forward and reverse zone file, ran named-chekckzone and restarted bind. it all worked fine. but i still get th same error when running nslookup on host1 or host1.dirks.crtn. "nslookup host1 ;; got SERVFAIL from 192.168.56.2, trying next server server: 192.56.2 address: 192.168.56.2#53 server cant fint host1: NXDOMAIN" It might not be important, but the request tok longer time to finish than it did before. do you have any other suggestion on what the problem might be? :) – Madde Apr 15 '15 at 23:41
  • Does reverse lookup work now? – Doug Smythies Apr 15 '15 at 23:49
  • Hey again :), sadly no, I tried to lookup host1 ip address "nslookup 192.168.56.21 ;; Got SERVFAIL reply from 192.168.56.2, trying next server ;; Got SERVFAIL reply from 192.168.56.2, trying next server server: 192.168.1.1 address 192.168.1.1#63 server can't find 21.56.16.192.in-addr.arpa: SERVFAIL" it is like the dns server doesn't find the files. is it possible for me to check if the the dns server finds the forward and reverse zone file? – Madde Apr 15 '15 at 23:57
  • Well, try them not in the zones sub-directory. Mine are in /etc/bind. See if there is anything of note in /var/log/syslog search for "named". Meanwhile I'll look at your question again. – Doug Smythies Apr 16 '15 at 0:06
  • You don't have dnsmasq running do you? – Doug Smythies Apr 16 '15 at 0:10
1

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.