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 beexample.com
. It could besome-hostname
onexample.com
likefoo.example.com
but notexample.com
since it implies that your zone iscom
and B's hostname isexample
which is not consistent with the configuration you provided.There is an error in
/etc/bind/db.example.com
.This lines is used to specify domain name server. Here you just said :
which should be
Then you specify the A records related to the NS records (i.e your nameserver IP adress) :
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
This is the same for the SOA records in
db.example.com
:@ IN SOA example.com. root.example.com.
should be :
SOA records in
db.192
should be exactly the same asdb.example.com
, no needs to write1.168.192.in-addr.arpa.
.Then again your NS and PTR records aren't correct, they should be :
I hope I didn't miss something but for last piece of advice Bind9 is packaged with two scripts
named-checkzone
andnamed-checkconf
. The former can check zone file (i.edb.192
anddb.example.com
) and the latter can check Bind9 configuration (i.enamed.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.