Thursday, April 04, 2013

Installing and Configuring Bind DNS | Nameserver on Cent OS

Tech Blog - This is a short how to on setting up your own Domain Name Server for Cent OS 6, configuration should generally also applied to bind named package installed on other Linux flavour.


First we install bind using yum.

yum install -y bind.i686 bind-chroot.i686 

Once installed we edit named.conf

vi /etc/named.conf

Below is a sample configuration of named.conf, change IPs that applies to your network

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
        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";

        dnssec-enable no;
        dnssec-validation no;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";

//forwarders - for external dns queries, lets use opendns's IP or Router or ISP IP

       forwarders { 208.67.222.222; 208.67.220.220; 111.68.59.69; 192.168.1.1; };
        forward first;
        allow-transfer {
                                208.67.222.222;
                                208.67.220.220;
                                111.68.59.69;
                                192.168.1.1;
                                localhost;
                        };
//Change IP to your networks IP, Only allow queries from you internal network                 allow-recursion { 192.168.1.0/24; localhost; };
};
//for logging useful to check if something is wrong with your configuration, specially during initial statup

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

zone "." IN {
        type hint;
        file "named.ca";
};

//Your domains zone, see creting zone
zone "eondynamics.com" {
        type master;
        file "/var/named/data/eondynamics.com.zone";
};
//for reverse lookup
zone "1.168.192.in-addr.arpa" {
        type master;
        file "/var/named/data/1.168.192.zone";
};

After editing named.conf, let us now our zones for forward and reverse lookup

vi  /var/named/data/eondynamics.com.zone

Below is a sample zone

$TTL 3D
@    IN    SOA    eondynamics.com. ns1.eondyanmics.com.(
            9989    ; Serial
            8H    ; Refresh
            2H    ; Retry
            4W    ; Expire
            1D )    ; Minimum
        NS    router.eondynamics.com.
;@    IN    MX    10 mail.eondynamics.com.

ns1.eondynamics.com.    A    192.168.1.181
router                  A       192.168.1.1
desktop12               A       192.168.1.98

Now to setup for reverse lookup


vi /var/named/data/1.168.192.zone
Below is a sample entry
$TTL 3D
@    IN    SOA    router.eondynamics.com. ns1.eondyanmics.com.(
            9989    ; Serial
            8H    ; Refresh
            2H    ; Retry
            4W    ; Expire
            1D )    ; Minimum
1.168.192.in-addr.arpa. IN        NS    router.eondynamics.com.

181 PTR ns1.eondynamics.com.
1   PTR router.eondynamics.com.
98  PTR desktop12.eondynamics.com.








Once done let start named

#/etc/init.d/named start

then point a workstation to your DNS and see if your DNS is working

# nslookup desktop12
Server:        192.168.1.181
Address:    192.168.1.181#53

Name:    desktop12.eondynamics.com
Address: 192.168.1.98
# dig eondynamics.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.4 <<>> eondynamics.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- 23028="" id:="" noerror="" opcode:="" query="" span="" status:="">
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;eondynamics.com.        IN    A

;; AUTHORITY SECTION:
eondynamics.com.    86400    IN    SOA    eondynamics.com. ns1.eondyanmics.com. 9989 28800 7200 2419200 86400

;; Query time: 0 msec
;; SERVER: 192.168.1.181#53(192.168.1.181)
;; WHEN: Tue Apr  2 11:26:01 2013
;; MSG SIZE  rcvd: 85


Then your done.

No comments:

For suggestion and concerns E-mail