How to configure bind on CentOS 6.3

DNS stands for Domain Name System and is a a hierarchical distributed naming system for computers, services, or any resource connected to the Internet or a private network. In other words DNS translate human readable hostnames such as test.org into machine readable ip addresses such as 89.36.25.239.

Preliminary notes
- Server Name: ns.test.org
- Server IP: 172.20.30.1/24

Install required software packages

yum install bind bind-libs bind-utils

Set BIND service to start on system boot

chkconfig named on

Start named service for generating some default configuration files.
/etc/init.d/named start

Note: In case the command above hangs there is an entropy problem. You should install haveged daemon. More details here.

If you don't want to install haveged daemon there is a workaround:

rndc-confgen -a -r /dev/urandom

Edit main configuration file and add zone entry of www.test.org

vim /etc/named.conf

options {
        forwarders { 8.8.8.8; 8.8.4.4; };
        listen-on port 53 { any; };
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query { any; };
        allow-query-cache { any; };
};

logging {
        channel default_debug {
            file "data/named.run";
            severity dynamic;
        };
};

zone "." IN {
        type hint;
        file "named.ca";
};
zone "test.org" {
        type master;
        file "test.org";
};
zone "30.20.172.in-addr.arpa" {
        type master;
        file "30.20.172.in-addr.arpa";
};

Create Zone files which we mentioned in named.conf file

cd /var/named
vim /var/named/test.org

$ORIGIN test.org.

$TTL 1H

test.org.          IN SOA ns.test.org. root.test.org. (
                                2012062600      ; serial
                                12H             ; refresh
                                2H              ; retry
                                1W              ; expiry
                                2D )            ; minimum

test.org.       IN    NS   ns.test.org.

ns.test.org.    IN    A    172.20.30.1

www10          IN    A    172.20.30.10
www11          IN    A    172.20.30.11
www12          IN    A    172.20.30.12
www13          IN    A    172.20.30.13
www14          IN    A    172.20.30.14
www15          IN    A    172.20.30.15

vim /var/named/30.20.172.in-addr.arpa

$ORIGIN 30.20.172.in-addr.arpa.

$TTL 2D

@          IN SOA ns.test.org. root.test.org. (
                                2012062600      ; serial
                                12H             ; refresh
                                2H              ; retry
                                1W              ; expiry
                                2D )            ; minimum

@     IN    NS     ns.test.org.

1     IN    PTR    ns.test.org.

10    IN    PTR    www10.test.org.
11    IN    PTR    www11.test.org.
12    IN    PTR    www12.test.org.
13    IN    PTR    www13.test.org.
14    IN    PTR    www14.test.org.
15    IN    PTR    www15.test.org.

Restart named service

/etc/init.d/named restart

Update /etc/resolv.conf file

echo "search test.org" > /etc/resolv.conf
echo "nameserver 127.0.0.1" >> /etc/resolv.conf

Source: http://www.broexperts.com/2012/03/linux-dns-bind-configuration-on-centos-6-2/

Leave a Reply

Your email address will not be published. Required fields are marked *