| Ain't nothin' to it, really! |
Below are steps listed that will help you install BIND9 and configure BIND9 as a forwarding DNS server. For an in depth explanation of DNS, how it works, how to configure it, read O'Reilly's book DNS and BIND 5th edition and other resources regarding DNS.
Step 1: Install LINUX or UNIX - You'll have to figure this out on your own or wait until I put one together.
Step 3: Update your Linux installation:
sudo apt-get update
sudo apt-get upgrade
Step 4: Install BIND9 and BIND9Utils:
sudo apt-get install bind9 bind9utils
sudo vi /etc/network/interfaces
# The setting for appropriate network interface
auto eth0
iface eth0 inet static
address 192.168.xxx.xxx
netmask 255.255.xxx.xxx
broadcast 192.168.xxx.xxx
gateway 192.168.xxx.xxx
Step 6: Change resolver:
sudo vi /etc/resolv.conf
nameserver 192.168.xxx.xxx
Step 7: Restart your network interface:
sudo service networking restart
Step 8: Make directory in which your zones files will reside:
sudo mkdir /etc/bind/zones
sudo mkdir /etc/bind/zones/master
Step 9: Create your zone files:
sudo touch db.sub.domain.tld (i.e. db.internal.mchowdhury.com)
sudo touch db.192.168.xxx
Step 10: Edit your zone file (db.sub.domain.tld):
;
; BIND data file for sub.domain.tld
;
$TTL 86400@ IN SOA host.sub.domain.tld. admin.domain.tld. (
05232013 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Negative caching TTL
;
@ IN NS host.sub.domain.tld.
sub.domain.tld. IN A 192.168.xxx.xxx
host IN A 192.168.xxx.xxx
host2 IN A 192.168.xxx.xxx
host3 IN A 192.168.xxx.xxx
Step 11: Edit your reverse zone file (db.192.168.xxx)
;BIND reverse data file for 101.168.192.in-addr.arpa
;
$TTL 86400
xxx.168.192.in-addr.arpa. IN SOA host.sub.domain.tld. admin.domain.tld. (
05232013 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Negative caching TTL
;
xxx.168.192.in-addr.arpa. IN NS host.sub.domain.tld.
xxx.xxx.168.192.in-addr.arpa. IN PTR host.sub.domain.tld.
xxx.xxx.168.192.in-addr.arpa. IN PTR host.sub.domain.tld.
Step 12: Indicate the servers to which you want your DNS server to forward DNS requests if it doesn't know the answer:
sudo vi /etc/bind/named.conf.options
forwarders {
xxx.xxx.xxx.xxx;xxx.xxx.xxx.xxx;
};
Step 13: Check your configuration:
sudo named-checkconf
Step 14: Check zone file:
sudo named-checkzone sub.domain.tld /etc/bind/zones/master/db.sub.domain.tld
If all goes well, you should see something along the lines of:
zone sub.domain.tld/IN: loaded serial 05232013
OK
Step 15: Check reverse zone file:
sudo named-checkzone xxx.168.192.in-addr.arpa /etc/bind/zones/master/db.192.168.xxx
If all goes well, you should see something along the lines of:
zone xxx.168.192.in-addr.arpa/IN: loaded serial 05232013
OK
Step 16: Restart BIND9:
sudo service bind9 restart
At this point, you're done! You can check if things are working by doing some digging :-). For instance, on your server, run the following command:
dig google.com
You should get output similar to:
; <<>> DiG 9.7.3 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60050
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 13, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 300 IN A 74.125.228.78
google.com. 300 IN A 74.125.228.64
google.com. 300 IN A 74.125.228.65
google.com. 300 IN A 74.125.228.66
google.com. 300 IN A 74.125.228.67
google.com. 300 IN A 74.125.228.68
google.com. 300 IN A 74.125.228.69
google.com. 300 IN A 74.125.228.70
google.com. 300 IN A 74.125.228.71
google.com. 300 IN A 74.125.228.72
google.com. 300 IN A 74.125.228.73
;; AUTHORITY SECTION:
com. 167884 IN NS l.gtld-servers.net.
com. 167884 IN NS i.gtld-servers.net.
com. 167884 IN NS j.gtld-servers.net.
com. 167884 IN NS m.gtld-servers.net.
com. 167884 IN NS a.gtld-servers.net.
com. 167884 IN NS k.gtld-servers.net.
com. 167884 IN NS c.gtld-servers.net.
com. 167884 IN NS b.gtld-servers.net.
com. 167884 IN NS f.gtld-servers.net.
com. 167884 IN NS g.gtld-servers.net.
com. 167884 IN NS d.gtld-servers.net.
com. 167884 IN NS e.gtld-servers.net.
com. 167884 IN NS h.gtld-servers.net.
;; Query time: 29 msec
;; SERVER: 192.168.xxx.xxx#53(192.168.xxx.xxx) <-- Response provided by your server.
;; WHEN: Thu May 23 19:29:21 2013
;; MSG SIZE rcvd: 428