Tuesday, April 10, 2012

Step by Step DNS (bind9) Server Configuration

=====================
Step 1.Check the Installation
    => dpkg --list | grep 'bind9'
    => dpkg -s bind9

Step 1.a. Check the status of bind9
=> lsof | grep bind9
=> pgrep bind9
=> service bind9 status
=> netstat -ntlp | grep bind9    
=> netstat -ntlp | grep  53

Step 2. Remove previous Installation (if wanted)
    => sudo apt-get --purge remove bind9
       delete all the folders
    => rm -rf /etc/bind

Step 3. Install bind9
    => apt-get install bind9

Step 4. Configure bind9 as caching server
    => cd /etc/bind/
    => gedit named.conf.options
options {
       directory "/var/cache/bind";
   
    forwarders {
            132.10.4.2;
            8.8.8.8;
            //IP Adresses of actual nameservers
           };
        *    auth-nxdomain no;    # conform to RFC1035
        *    listen-on-port 53 { 127.0.0.1; };
};

Step 5. Restart bind9
=> /etc/init.d/bind9 restart

Step 6. Configure Forward Zone
Step 6.a. Edit /etc/bind/named.conf.local file
    => gedit named.conf.local

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

Step 6.b. Create database for Forward Zone
    => touch db.itacbd.com
    => chmod a+x db.itacbd.com
=> cp /etc/bind/db.local /etc/bind/db.itacbd.com
    =>  gedit db.itacbd.com
    ;
    ; BIND data file for forward zone
    ;
    $TTL    604800
    @    IN    SOA    ns.itacbd.com. root.itacbd.com. (
                      3            ; Serial
                 604800        ; Refresh
                  86400        ; Retry
                2419200        ; Expire
                 604800 )    ; Negative Cache TTL
    ;
    @    IN    NS    ns.itacbd.com.
    itacbd.com.    A    192.168.1.1
    ns    IN    A    192.168.1.1
    www    IN    A    192.168.1.1

Step 6.c. Restart bind9
=> /etc/init.d/bind9 restart

Step 7. Configure Reverse Zone file
Step 7.a. Edit /etc/bind/named.conf.local file
    =>  gedit named.conf.local

    // Reverse zone file
    //192.168.1.1
    zone "1.168.192.in-addr.arpa" {
        type master;
        notify no;
        file "/etc/bind/rev.db.192";
    };

Step 7.b. Create database for Reverse Zone file
    => touch rev.db.192
    => chmod a+x rev.db.192
    => sudo cp /etc/bind/db.127 /etc/bind/rev.db.192
    =>  gedit db.192
    ;
    ; BIND reverse data file
    ;
    $TTL    604800
    @    IN    SOA    ns.itacbd.com. root.itacbd.com. (
                      2        ; Serial
                 604800        ; Refresh
                  86400        ; Retry
                2419200        ; Expire
                 604800 )    ; Negative Cache TTL
    ;
    @       IN      NS      ns.
    1       IN      PTR     ns.itacbd.com.

Step 7.c. Restart bind9
=> sudo /etc/init.d/bind9 restart

Step 8. Test Configured bind9
Step 8.a. Change resolve.conf file
    => gedit /etc/resolv.conf
        nameserver    192.168.1.1

Step 8.b. Test Configured domain
    => host itacbd.com 127.0.0.1
    => dig itacbd.com
    => nslookup itacbd.com
    => ping itacbd.com
    => dig -x 127.0.0.1
    =>dig 1.168.192.in-addr.arpa. AXFR
(You should see output resolving 1.168.192.in-addr.arpa. to your nameserver. )

Step 8.c. Test Zone file
    => named-checkzone itacbd.com /etc/bind/db.itacbd.com
    => named-checkzone example.com /etc/bind/rev.db.192
   
Step 9. Troubleshoot using log file
    => tail -f /var/log/syslog

To Rename a file
    => mv /etc/bind/rev.db /etc/bind/rev.db.192


------- arahman.iit@gmail.com --------

No comments:

Post a Comment