DNS Server Setup Guide Line on Rhel 6 or Cent Os 6

***************************************************************
For Server Site
***************************************************************
***************************************************************


***************************************************************
Command line 
*******************************************************************

[root@server1 ~]#vim /etc/sysconfig/netwprk-scripts/ifcfg-eth0


*******************************************************************
Write it in this file
*******************************************************************

DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
IPADDR=192.168.10.2
PREFIX=24
GATEWAY=10.102.1.1
DNS1=192.168.10.2  (Computer )
HWADDR=00:16:EC:38:25:3D



Press ESC (Button)
:x


***************************************************************
Command line 
*******************************************************************

[root@server1  ~]#vim /etc/hosts

*******************************************************************
Edit hosts file
*******************************************************************



192.168.10.2 server1.howtoc.com server1 # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 server1.howtoc.com server1 localhost6.localdomain6 localhost6

Press ESC (Button)
:x



************************************************************************
End of the edit of hosts file
************************************************************************
Command line 
*******************************************************************

[root@server1  ~]#vim /etc/sysconfig/network


*******************************************************************
Edit network file
*******************************************************************


NETWORKING=yes
HOSTNAME=server1.howtoc.com

Press ESC (Button)
:x


************************************************************************
End of the edit of hosts file
************************************************************************
Command line 
*******************************************************************

[root@server1  ~]#vim /etc/resolve.conf

*******************************************************************
Edit resolve file
*******************************************************************


search howtoc.com
nameserver 192.168.10.2

Press ESC (Button)
:x


************************************************************************
End of the edit of hosts file
************************************************************************
Command line 
*******************************************************************

[root@server1  ~]#yum -y install bind*
[root@server1  ~]#updatedb

 # Find the named.conf file(Main configuration file of BIND)

[root@server1  ~]#locate named.conf
/etc/named.conf 
/usr/share/doc/bind-9.7.0/named.conf.default
/usr/share/doc/bind-9.7.0/sample/etc/named.conf 
/usr/share/logwatch/default.conf/services/named.conf
/usr/share/man/man5/named.conf.5.gz



***************************************************************
Command line 
*******************************************************************
Go to below path
*******************************************************************
[root@server1  ~]#cd /var/named/chroot/
[root@server1  chroot]#cd etc
[root@server1  etc]#pwd
/var/named/chroot/etc
[root@server1  etc]#cp /usr/share/doc/bind-9.7.0/named.conf.default named.conf 
[root@server1  etc]#chgrp named named.conf 
[root@server1  etc]#ll named.conf
f -rw-r--r--. 1 root named 930 Aug 3 07:58 named.conf 
[root@server1  etc]#vim  named.conf 

***********************************************************************
Edit named.conf file
***********************************************************************
//
// 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 {
 listen-on port 53 { 127.0.0.1;192.168.10.2; };
 /*listen-on-v6 port 53 { ::1; };*/
 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.10.0/24; };
 # transfer range ( set it if you have secondary DNS )
 allow-transfer { localhost; 192.168.10.0/24; };,
 recursion yes;

 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 "." IN {
 type hint;
 file "named.ca";
};

zone "sajed.com" IN {
                type master;
                file "forward.zone";
                allow-update { none; };
        };
zone "10.168.192.in-addr.arpa" IN {
                type master;
                file "reverse.zone";
                allow-update { none; };
        };

include "/etc/named.rfc1912.zones";


Press ESC (Button)
:x

***********************************************************************
End of the edit of named.conf file
***********************************************************************

[root@server1  etc]#vim /etc/named.rfc1912.zones

***********************************************************************
Edit named.rfc1912.zones file
***********************************************************************
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package 
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
// 
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

zone "sajed.com" IN {
 type master;
 file "forward.zone";
 allow-update { none; };
};

zone "localhost" IN {
 type master;
 file "named.localhost";
 allow-update { none; };
};

zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
 type master;
 file "named.loopback";
 allow-update { none; };
};

zone "10.168.192.in-addr.arpa" IN {
 type master;
 file "reverse.zone";
 allow-update { none; };
};

zone "0.in-addr.arpa" IN {
 type master;
 file "named.empty";
 allow-update { none; };
};


Press ESC (Button)
:x

***********************************************************************
End of the edit of named.rfc1912.zones file
***********************************************************************
[root@server1  etc]#/etc/init.d/named restart 
Stopping named: [ OK ] 
Starting named: [ OK ]
[root@server1  etc]#vim /etc/named.conf
[root@server1 named]#cp named.localhost forward.zone
[root@server1 named]#cp named.loopback reverse.zone
[root@server1 named]#vim /var/named/forward.zone


***********************************************************************
Edit forward.zone file
***********************************************************************

$TTL 1D
@ IN SOA server1.sajed.com. root.sajed.com. (
                         0 ; serial
                        1D ; refresh
                        1H ; retry
                        1W ; expire
                      3H ) ; minimum
             

                  IN    NS server1.sajed.com.
                  IN     A 192.168.10.2
server1           IN     A 192.168.10.2

Press ESC (Button)
:x


***********************************************************************
End of the edit of forward.zone file
***********************************************************************

[root@server1 named]#vim /var/named/reverse.zone

***********************************************************************
Edit reverse.zone file
***********************************************************************
$TTL 1D
@ IN SOA server1.sajed.com. root.sajed.com. (
                         0 ; serial
                        1D ; refresh
                        1H ; retry
                        1W ; expire
                      3H ) ; minimum
                 
              IN         NS server1.sajed.com.
              IN        PTR sajed.com.
              IN          A 255.255.255.0
2             IN        PTR server1.sajed.com.

Press ESC (Button)
:x


***********************************************************************
End of the edit of reverse.zone file
***********************************************************************
Command line 
***************************************************************
[root@server1 named]#chgrp named  forward.zone
[root@server1 named]#chgrp named  reverse.zone
[root@server1 named]#/etc/init.d/named  restart
[root@server1 named]#dig server1.howtoc.com
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> server1.sajed.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50351
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;server1.sajed.com.           IN      A

;; ANSWER SECTION:
server1.sajed.com.    86400   IN      A       192.168.10.2

;; AUTHORITY SECTION:
sajed.com.              86400   IN      NS      server1.sajed.com.

;; Query time: 0 msec
;; SERVER: 192.168.10.2#53(192.168.10.2)
;; WHEN: Tue Oct 16 10:13:40 2012
;; MSG SIZE  rcvd: 67

***************************************************************
Command line 
*******************************************************************
[root@server1 named]#dig -x 192.168.10.2
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> -x 192.168.10.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45077
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;2.10.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
2.10.168.192.in-addr.arpa. 86400 IN     PTR     server1.sajed.com.

;; AUTHORITY SECTION:
10.168.192.in-addr.arpa. 86400  IN      NS      server1.sajed.com.

;; ADDITIONAL SECTION:
server1.howtoc.com.    86400   IN      A       192.168.10.2

;; Query time: 1 msec
;; SERVER: 192.168.10.2#53(192.168.10.2)
;; WHEN: Tue Oct 16 10:13:08 2012
;; MSG SIZE  rcvd: 106

***************************************************************
Command line 
*******************************************************************
[root@server1 named]#nslookup
> server1.sajed.com
Server:         192.168.10.2
Address:        192.168.10.2#53

Name:   server1.sajed.com
Address: 192.168.10.2
> 192.168.10.2
Server:         192.168.10.2
Address:        192.168.10.2#53

2.10.168.192.in-addr.arpa       name = server1.howtoc.com.
>

Comments