BIND can't resolve a domain name

9,799

Solution 1

It sounds as if you are having some difficulty, so here are two (hopefully) working examples for you. Note that the first option (the .com zone) will likely prevent resolution of normal .com domains (e.g. google.com). The second option (the dns1.com zone) does not have this drawback.

Example .com Zone Files

ex. /etc/bind/named.conf.local

; "db.com.tld" is a random name - use whatever you like.
; The same goes for "db.rev.192".
;
; Likewise, you can adjust your "allow-transfer" settings,
; etc. as needed.

zone "com." IN {
    type master;
    file "/etc/bind/zones/db.com.tld";
    allow-transfer { none; };
};

zone "56.168.192.in-addr.arpa" IN {
    type master;
    file "/etc/bind/zones/db.rev.192";
    allow-transfer { none; };
};


ex. /etc/bind/zones/db.com.tld

; BIND data file for TLD ".com"
;
; This will likely break real ".com" websites (i.e. anything not listed here).

$TTL 3600
@   IN  SOA     com.    admin.com. (
                2018040501  ; Serial
                604800      ; Refresh period
                86400       ; Retry interval
                2419200     ; Expire time (28 days... later)
                604800 )    ; Negative Cache TTL (1 week)

; Name Servers - NS records
@       IN NS  ns1.com.   ; This is required
@       IN NS  ns2.com.   ; You should have two name servers

; Name Servers - A records
ns1                 IN A        192.168.56.3        ; This is required
ns2                 IN A        192.168.56.3        ; You should have two name servers

; Our domains/sub-domains
dns1                IN A        192.168.56.3        ; dns1.com
host1.dns1          IN A        192.168.56.7        ; host1.dns1.com
host2.dns1          IN A        192.168.56.8        ; host2.dns1.com

Note that is okay to use a period like this, though arguably redundant in this case:

;ok.period.com.     IN A        192.168.56.3        ; ok.period.com -> FQDN

And this is what you should avoid:

;no.period.         IN A        192.168.56.3        ; Don't use periods for sub-domains
;no.period.com      IN A        192.168.56.3        ; While this works, this is actually accessed as no.period.com.com!


ex. /etc/bind/zones/db.rev.192

; BIND reverse data file.
; The domain, etc. used should be a listed 'zone' in named.conf. 

$TTL 86400
@   IN SOA      com.    admin.com. (
                2018040501  ; Serial
                10800       ; Refresh
                3600        ; Retry
                604800      ; Expire
                86400 )     ; Minimum

; In this case, the number just before "PTR" is the last octet 
; of the IP address for the device to map (e.g. 192.168.56.[3])

; Name Servers
@       IN NS   ns1.com.
@       IN NS   ns2.com.

; Reverse PTR Records
3       IN PTR  dns1.com.   
7       IN PTR  host1.dns1.com.
8       IN PTR  host2.dns1.com.

Note that the setup above likely limits your options with regards to having your machines access .com domains other than the ones you create (i.e. they will likely not be able to access them). If you wish them to access foreign .com domains, you can try the narrower approach below.


Example dns1.com Zone Files

ex. /etc/bind/named.conf.local

; "db.dns1.com" is a random name - use whatever you like.
;
; Likewise, you can adjust your "allow-transfer" settings,
; etc. as needed.

zone "dns1.com" IN {
    type master;
    file "/etc/bind/zones/db.dns1.com";
    allow-transfer { none; };
};

You can use the same named.conf.local reverse zone entry as above.


ex. /etc/bind/zones/db.dns1.com

; BIND data for http://dns1.com

$TTL 3600 
@   IN SOA      ns1.dns1.com.   admin.dns1.com. (
                2018040501  ; Serial
                604820      ; Refresh
                86600       ; Retry
                2419600     ; Expire
                604600 )    ; Negative Cache TTL

; Name Servers - NS records
@       IN NS   ns1.dns1.com.   ; This is required
@       IN NS   ns2.dns1.com.   ; You should have two name servers

; Name Servers - A records
ns1                 IN A        192.168.56.3        ; This is required
ns2                 IN A        192.168.56.3        ; You should have two name servers

; Our domains/sub-domains
dns1.com.           IN A        192.168.56.3         ; dns1.com 
host1               IN A        192.168.56.7         ; host1.dns1.com
host2               IN A        192.168.56.8         ; host2.dns1.com


ex. /etc/bind/zones/db.rev.192

; BIND reverse data file.
; The domain, etc. used should be a listed 'zone' in named.conf. 

$TTL 86400
@   IN SOA      dns1.com.   admin.dns1.com. (
                2018040501  ; Serial
                10800       ; Refresh
                3600        ; Retry
                604800      ; Expire
                86400 )     ; Minimum

; In this case, the number just before "PTR" is the last octet 
; of the IP address for the device to map (e.g. 192.168.56.[3])

; Name Servers
@       IN NS   ns1.dns1.com.
@       IN NS   ns2.dns1.com.

; Reverse PTR Records
3       IN PTR  dns1.com.   
7       IN PTR  host1.dns1.com.
8       IN PTR  host2.dns1.com. 

Solution 2

Your zone file is wrong - on lines 20 and 21 as suggested. Specifically it should not have the "." after host1 and host2.

The . means that this is absolute, rather then relative to the zone - so its balking at the domain name host1 and has no entry for host1.com

Share:
9,799

Related videos on Youtube

None
Author by

None

Updated on September 18, 2022

Comments

  • None
    None over 1 year

    I have a BIND ubuntu server as a private DNS server for com zone and two hosts (web servers). The three are virtual hosts using virtual box and connect together using a virtual host card.

    I have this configuration file in the DNS server for forward resolution:

    $TTL    604800
    
    @       IN      SOA     dns1.com. admin.com. (
                                  19        ; Serial
                             604820         ; Refresh
                              86600         ; Retry
                            2419600         ; Expire
                             604600 )       ; Negative Cache TTL
    
    ; name servers - NS records
        IN  NS  dns1.com.
    
    ; name servers - A records
    dns1.com.          IN      A       192.168.56.3
    
    ; 192.168.56.0/24 - A records
    @           IN      NS      dns1.com.
    host1.          IN      A   192.168.56.7
    host2.          IN      A   192.168.56.8
    

    I try to connect to both hosts using their domain name. The first one opens correctly. The second one can never open.

    Both are pingaple. Here is the second host ping result from my machine: C:\Users\e>ping 192.168.56.8

    Pinging 192.168.56.8 with 32 bytes of data:
    Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
    

    I am able to resolve host2.com if I use the local host file in my windows machine by adding this entry:

    192.168.56.8    host2.com
    

    I can not find why my DNS server can not resolve host2 but can resolve host1?

    Here is the named.conf.local file:

    zone ".com" {
        type master;
        file "/etc/bind/forward.host1.com";
    };
    
    zone "56.168.192.in-addr.arpa"{
        type master;
        file "/etc/bind/reverse.host1.com";
    };
    

    I do not think the file names forward.host1.com reverse.host1.com has any effect on the resolution? do they?

    EDIT: To check the configurations:

    /etc/bind$ sudo named-checkzone com forward.host1.com
    forward.host1.com:20: ignoring out-of-zone data (host1)
    forward.host1.com:21: ignoring out-of-zone data (host2)
    zone com/IN: loaded serial 19
    OK
    

    Can anyone point to me why I can't resolve host2?

    EDIT: After an answer suggested, the file has been updated to the followin but without any hope. I now can not reach neither host1 nor host2 although they are up and running and I can reach them by IP:

    $TTL    604800
    
    
    
    @       IN      SOA     dns1.com. admin.com. (
    
                                  24        ; Serial
    
                             604820         ; Refresh
    
                              86600         ; Retry
    
                            2419600         ; Expire
    
                             604600 )       ; Negative Cache TTL
    
    
    
    ; name servers - NS records
    
        IN  NS  dns1.com.
    
    
    ; name servers - A records
    
    dns1.com          IN      A       192.168.56.3
    
    
    ; 192.168.56.0/24 - A records
    
    @           IN      NS      dns1.com.
    
    host1           IN      A   192.168.56.7
    
    host2           IN      A   192.168.56.8
    
  • None
    None about 6 years
    Thanks but unfortunately it did not solve my problem. See the updated config plz.
  • davidgo
    davidgo about 6 years
    What OS are you running, and what nameservers are set in that OS? (I ask for 2 reasons - If you are using a Unix type OS we can use tools like DIG to find out what is going on, and if the primary nameserver is not being used by the OS, then this setup is going to be ignored). Also, am I correct in my belief that the changes I suggested means the zone loads without warnings?
  • None
    None about 6 years
    I use ubuntu for the DNS and the hosts. Can you provide more details in what I should look for in the dig? dig for which server exactly? the dns server or the hosts? After the changes I ran: :/etc/bind$ sudo named-checkzone com forward.com and got zone com/IN: loaded serial 27 OK and then ran :/etc/bind$ sudo named-checkzone 56.168.192.in-addr.arpa reverse.com and got zone 56.168.192.in-addr.arpa/IN: loaded serial 5 OK. Note that I changed the files names to forward.com and reverse.com as an attempt but I do not think they are releveant.
  • davidgo
    davidgo about 6 years
    You are right - file names are not important. What does /etc/resolve.conf on your host contain? Does "dig host1.com A" and dig @192.168.56.3 host1.com A" return the same result?
  • None
    None about 6 years
    I still can not access the website using its domain name but can access it with IP. Can you make me a favour and post the other necessary files for dns? I expect I'm doing something wrong in the other necessary files like the named.conf.local and the reverse.
  • None
    None about 6 years
    It worked after I added a dot in this line: dns1.com IN A 192.168.56.3 to become dns1.com. IN A 192.168.56.3
  • Anaksunaman
    Anaksunaman about 6 years
    I am glad you got it at least partially figured out. If you are still interested, I have posted two different (hopefully typo free) sets of configuration files for you to look over. They may or may not be useful to you at this point but they are there. In any case, good luck. =)