Wednesday, July 14, 2010

Installing & Configuring Bind 9 (Ubuntu/Debian)

Numerous articles have been written about bind9, most of them are long, clumpy and not really explain how things work in detail. In this fairly short article I will try to give my point of view and make thing a bit more clear especially for new admins, so lets start!

First install bind9:

#apt-get install bind9

Next, open /etc/bind/named.conf.local, here you will need to add your zone name + the appropriate zone db file.
You will also need to add reverse look zone + db file (for reverse lookups), this is how your file will generally look like. 

* Note:I've used 192.168.0.0/24 subnet in my case:


#vi /etc/bind/named.conf.local



zone "linux.lan" {
type master;
file "/etc/bind/zones/linux.lan.db";
};
 

zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};



Next, add your ISP's DNS server to /etc/bind/named.options as a forwarder, This means is when your DNS server will not know the answer it will query the forwarder and provide a non-authoritative answer.

Create the directory that will contain the zones db:

# mkdir /etc/bind/zones


Create the db file:

#vi /etc/bind/zones/linux.lan.db 

linux.lan. IN SOA dns1.linux.lan. admin.linux.lan. (

2006081401
28800
3600
604800
38400 )

linux.lan. IN NS dns1.linux.lan.
IN A 192.168.0.7
dns1 IN A 192.168.0.7



It's time to create a reverse zone db-file, pay attention that the servers PTR record has 7, that stands for 192.168.0.7:

#vi /etc/bind/zones/rev.rev.0.168.192.in-addr.arpa

@ IN SOA linux.lan. admin.linux.lan. (
2006081401;
28800;
604800;
604800;
86400 );

IN NS dns1.linux.lan.
7 IN PTR linux.lan.



Next, restart bind to changes to take effect:


# /etc/init.d/bind9 restart



To make searches more convinient, you can (and should) add your domain suffix to /etc/resolv.conf

#echo "search linux.lan" >> /etc/resolv.conf

Test your DNS via host,nslookup or dig commands:

#host dns1
dns1.linux.lan has address 192.168.0.7


Works like magic!

No comments: