How to Setup an internal DNS Server with Bind

Install Bind9

# apt-get install bind9

Setup named.conf

# mv /etc/bind/named.conf.local /etc/bind/named.conf # vim /etc/bind/named.conf

zone "somedomain.com" {
        type master;
        file "/etc/bind/somedomain.com.db";
};

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

Setup named.conf.options

Replace XXX.XXX.XXX.XXX with your External DNS.

# vim /etc/bind/named.conf.options

forwarders {
    XXX.XXX.XXX.XXX;
};

Setup somedomain.com.db zone file

# touch /etc/bind/somedomain.com.db # vim /etc/bind/somedomain.com.db

@        IN      SOA     ns1.somedomain.com. admin.somedomain.com. (
                         2006081401;
                         28800;
                         3600;
                         604800;
                         38400;
)
         IN      NS      ns1.somedomain.com.
         IN      A       192.168.2.151
www      IN      A       192.168.2.151
ns1      CNAME   www

Setup reverse zone file

Same here 2.168.192 with your local subnet. 151 below refers to your DNS server IP (192.168.2 151 for example)

# touch /etc/bind/rev.2.168.192.in-addr.arpa # vim /etc/bind/rev.2.168.192.in-addr.arpa

@       IN    SOA     ns1.somedomain.com.    admin.somedomain.com. (
                      2006081401;
                      28800;
                      604800;
                      604800;
                      86400;
)
        IN    NS      ns1.somedomain.com.
151     IN    PTR     somedomain.com

Make DNS server reference itself

# vim /etc/resolve.conf

nameserver      127.0.0.1

Restart bind9 daemon

# /etc/init.d/bind9 restart

Now we Test

# dig somedomain.com # nslookup somedomain.com

Red CrossHurricane Katrina XML FOAF 0.1 W3C XHTML 1.0 W3C CSS valid GET Firefox NO Software Patents