Thursday, July 4, 2013

CentOS 5.9 - Bind DNS Server

install bind
# yum  -y install  bind
# service  named start


vi   /etc/sysconfig/network-script/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=x.x.x.x
NETMASK=255.255.255.252
DNS1=127.0.0.1
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no

restart the network service
#service network  restart

/etc/resolv.conf  will be change to
nameserver  127.0.0.1

Correct the Date Time Setting
#date -s "2013-7-4 09:37:00"

Check hostname
#cat  /etc/sysconfig/network
OR
#hostname --fqdn

Check hosts file /etc/hosts
-------------------------------------------------------------------------------------------------
vi  /etc/named.conf
options {
        // listen-on port 1053 { 127.0.0.1; 192.168.20.33; };
        listen-on port 53 { 127.0.0.1; 192.168.20.33; };
        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     { localhost; 192.168.20.0/24; };
        forwarders { x.x.x.x; x.x.x.x; };
        recursion yes;
        max-cache-size 100m;
        cleaning-interval 60;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

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

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

zone "mmx.com" IN {
        type master;
        file "mmx.com.zone";
 };

zone "20.168.192.in-addr.arpa" IN {
        type master;
        file "mmx.com.rr.zone";
        allow-update { none; };
};

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

include "/etc/named.rfc1912.zones";
-------------------------------------------------------------------------------------------------
vi  /var/named/mmx.com.zone
$ORIGIN mmx.com.
$TTL 86400
@       IN      SOA     dns1.mmx.com.  itsupport.mmx.com. (
        2013070401 ;serial
        21600   ;refresh after 6 hours
        3600    ;retry after 1 hour
        604800  ;expire after 1 week
        86400 ) ;minimum TTL 1 day

             IN       NS      dns1.mmx.com.
             IN       MX      10      mail.mmx.com.
             IN        A       192.168.20.33
dns1      IN        A       192.168.20.33
cachex   IN        A       192.168.20.33
ftp         IN        A       192.168.20.33
mail       IN      CNAME   cachex
www     IN      CNAME   cachex
-------------------------------------------------------------------------------------------
vi  /var/named/mmx.com.rr.zone

$ORIGIN 20.168.192.in-addr.arpa.
$TTL 86400
@       IN      SOA     dns1.mmx.com.  itsupport.mmx.com. (
        2013070401 ;serial
        21600   ;refresh after 6 hours
        3600    ;retry after 1 hour
        604800  ;expire after 1 week
        86400 ) ;minimum TTL 1 day

@       IN      NS      cachex.mmx.com.
33      IN      PTR     cachex.mmx.com.
------------------------------------------------------------------------------------------------
Move /etc/rndc.key to /tmp
#mv  /etc/rndc.key   /tmp

Create new  rndc.key
#rndc-confgen   -a   -b   512

#ll   /etc/rndc.key
-rw-r--r-- 1 root root 141 Jul  4 14:13 /etc/rndc.key

Give writable permission to /var/named
#cd  /var/
#chmod  g+w  named
# ll  
drwxrwx---  5 root named 4096 Jul  4 14:58 named

#named-checkconf /etc/named.conf
#named-checkzone   mmx.com  /var/named/mmx.com.zone

#rndc dumpdb
#touch   /var/named/data/cache_dump.db
#touch   /var/named/data/named_mem_stats.txt
#touch   /var/named/data/named_stats.txt
#chown  -R  named   *
#chogrp  -R  named   *

#service  named  start
#tail     -f     /var/log/message

#dig   @127.0.0.1   www.msn.com
#rndc   flush   (clear the dns cache all the zones)
OR
#rndc  flush   viewname 
# rndc    querylog -> /var/log/message
# rndc    stats  -> var/named/data/named_stats.txt

No comments: