I decided to build a local DNS server today because I got sick of editing /etc/hosts on all the computers in my home network. My home network consists of 2 Macbook Pros, a Dell Mini 10v (hackintosh), a Mac Mini, and an Ubuntu Acer Aspire Revo. I have a whole bunch of other hosts, but these are the only ones I actively use on a regular basis. Also, another reason I wanted to build a local DNS server is because it would be a cool project to work on. I mean, how many people do you know can say they’ve built a DNS server? Anyways, I’m installing BIND on my Acer Aspire Revo. Below is the OS specs:
me@fett:~$ uname -a ; cat /etc/lsb-release
Linux fett 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:27:30 UTC 2010 i686 GNU/Linux
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION=”Ubuntu 10.04 LTS”
me@fett:~$
Below are the steps I used to get BIND running on Ubuntu 10.4 Lucid 32 bit.
Step 1. Install bind 9
sudo apt-get install bind9
Step 2. Edit /etc/bind/named.conf. In here, you will want to specify the zones you are create for forward and reverse name resolution. In my scenario, I am creating zone bleh.com and my network address is 192.168.1.
sudo vi /etc/bind/named.conf.local
This is how it looks on my setup:
zone "bleh.com" {
type master;
file "/etc/bind/zones/bleh.com.db";
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.1.168.192.in-addr.arpa";
};
Step 3. Edit /etc/bind/named.conf.options. What you want to enter here is the IP addresses of your provider in the forwarders section. In my case, the IPs I added are 68.87.76.1{82,34}.
sudo vi /etc/bind/named.conf.options
This is how it looks on my setup:
options {
directory "/var/cache/bind";
forwarders {
68.87.76.182;
68.87.78.134;
};
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
* Comments in bind config files are preceded by “//”. Comments in the zone files are preceded by “;”. This is something to keep in mind because I’ve read numerous forums where people would get this mixed up. This in turn screwed me up for hours.
Step 4. Create bleh.com zone file
sudo mkdir /etc/bind/zones
sudo vi /etc/bind/zones/bleh.com.db
This is how it looks in my setup:
$TTL 300
bleh.com. IN SOA bleh.com. root (
2006081401 ;Serial
28800 ;Refresh
3600 ;Retry
604800 ;Expire
38400 ) ;Negative Cache TTL
;
bleh.com. IN A 192.168.1.124
bleh.com. IN NS bleh.com.
bleh.com. IN MX 10 bleh.com.
zabrak IN A 192.168.1.110
fett CNAME bleh.com.
www CNAME bleh.com.
Step 5. Create reverse DNS zone file.
sudo vi /etc/bind/zones/rev.1.168.192.in-addr.arpa
This is how it looks in my setup:
$TTL 300
@ IN SOA bleh.com. root (
2006081401 ;Serial
28800 ;Refresh
604800 ;Retry
604800 ;Expire
86400 ) ;Negative Cache TTL
;
IN NS bleh.com.
124 IN PTR bleh.com.
110 IN PTR zabrak.bleh.com.
Step 6. Check zones and look at logs.
/usr/sbin/named-checkconf -z
tail -f /var/log/daemon.log
Step 7. Restart bind.
sudo /etc/init.d/bind9 restart
These are the steps I followed to get this up and running on my system. Hopefully you find this useful. I am by no means a DNS expert, but this setup works in my environment. If you see anything that could maybe make this more efficient, feel free to comment.