Tuesday, December 27, 2011

Configuring DNS Server on Red Hat Enterprise Linux 5(Part-2)


Secondary DNS Server Configuration

Change in Primary DNS Server:

Step-1: Edit the named.conf file for Secondary DNS .

[root@ns1 ~]# vi /etc/named.conf

Original 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
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {

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

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

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

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

zone "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.ip6.local";
     allow-update { none; };
};

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

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

zone "alphabd.net" IN {
     type master;
     file "alphabd.fz";

};

zone "201.207.210.in-addr.arpa" IN {
     type master;
     file "alphabd.rz";
};

Modified 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
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {

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

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

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

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

zone "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.ip6.local";
     allow-update { none; };
};

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

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

zone "alphabd.net" IN {
     type master;
     file "alphabd.fz";
     allow-update { 210.207.201.2; };          1st Change

};

zone "201.207.210.in-addr.arpa" IN {
     type master;
     file "alphabd.rz";
     allow-update { 210.207.201.2; };            2nd Change
};

Step-2:  Edit Forward Lookup zone file for Secondary DNS server record

[root@ns1 ~]# cd /var/named/chroot/var/named/
[root@ns1 named]# vi alphabd.fz

Original File:  alphabd.fz

$TTL 86400
@          IN SOA     ns1.alphabd.net.       root.alphabd.net. (
                          2011022500 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS     ns1.alphabd.net.
ns1      IN A       210.207.201.1

Modified File:  alphabd.fz

$TTL  86400
@           IN SOA      ns1.alphabd.net.       root.alphabd.net. (
                              2011022500  ; serial (d. adams)
                              3H          ; refresh
                              15M         ; retry
                              1W          ; expiry
                              1D )        ; minimum

            IN  NS            ns1.alphabd.net.
            IN  NS            ns2.alphabd.net.
ns1        IN  A             210.207.201.1
ns2         IN  A             210.207.201.2
www         IN  CNAME         ns1.alphabd.net.

 Step-3:  Edit Reverse Lookup zone file for Secondary DNS server record

[root@ns1 named]# vi alphabd.rz

Original File:  alphabd.rz

$TTL  86400
@           IN SOA      ns1.alphabd.net.       root.alphabd.net. (
                              2011022500  ; serial (d. adams)
                              3H          ; refresh
                              15M         ; retry
                              1W          ; expiry
                              1D )        ; minimum

            IN NS       ns1.alphabd.net.
1          IN PTR      ns1.alphabd.net.

Modified File:  alphabd.rz

$TTL  86400
@           IN SOA      ns1.alphabd.net.       root.alphabd.net. (
                              2011022500  ; serial (d. adams)
                              3H          ; refresh
                              15M         ; retry
                              1W          ; expiry
                              1D )        ; minimum

              IN NS           ns1.alphabd.net.
              IN NS           ns2.alphabd.net.
1            IN PTR          ns1.alphabd.net.
2             IN PTR          ns2.alphabd.net.

Step-4:    Check the named.conf & zone file by following this commands,

[root@ns1 ~]# named-checkzone  alphabd.net  /var/named/chroot/var/named/
alphabd.fz
[root@ns1 ~]# named-checkzone  alphabd.rz   /var/named/chroot/var/named/
alphabd.rz


Step-5:  Edit the resolv.conf file by following this command

[root@ns1 named]# vi /etc/resolv.conf

search alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.2

Step-6:  Start & stop all the required services.

[root@ns1 ~]# service iptables stop
[root@ns1 ~]# service network restart
[root@ns1 ~]# chkconfig named on
[root@ns1 ~]# service named restart

Change In Secondary DNS Server:

Step-1:  To check bind and caching-nameserver  rpm package is installed or not by following this                            command:
                       
(if installed then it will show bind packages)

[root@ns2 ~]# rpm -qa | grep –i bind*    or
[root@ns2 ~]#  rpm –qa bind*

bind-chroot-9.3.6-4.P1.el5
bind-libs-9.3.6-4.P1.el5
ypbind-1.19-12.el5
bind-9.3.6-4.P1.el5
bind-utils-9.3.6-4.P1.el5
bind-sdb-9.3.6-4.P1.el5
bind-devel-9.3.6-4.P1.el5
bind-libbind-devel-9.3.6-4.P1.el5
system-config-bind-4.0.3-4.el5

[root@ns2 ~]# rpm -qa caching-nameserver*  

Caching-nameserver-9.3.6-4.P1.el5

            If not installed, then installed the packages using  Yum command:

[root@ns2 ~]# Yum Install bind* caching-nameserver*

Step-2: Check and Configure the Network Card:

[root@ns2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

(Original File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes

(Modified File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPV6INIT=no
IPADDR=210.207.201.2
NETMASK=255.255.255.0
NETWORK=210.207.201.0
BROADCAST=210.207.201.255


After changing you have to reload/restart the NIC(eth0) card by following command:

[root@ns2 ~]# ifdown eth0
[root@ns2 ~]# ifup eth0
[root@ns2 ~]# service network restart

Step-3:  After complete the NIC configure you have to change the host name by following this                             command:

[root@ns2 ~]# vi /etc/sysconfig/network

(Original File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ns2

Step-4: Now Edit hosts file for host name resolution by following this command:

[root@ns2 ~]# vi /etc/hosts

(Original File):

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost

(Modified File):

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
210.207.201.1   ns1.alphabd.net      ns1
210.207.201.2   ns2.alphabd.net      ns2

Step-5:  Copy & Rename the named.rfc1912.zones file to named.conf file & Change the ownership & permission by following this command:

[root@ns2 ~]# cd /var/named/chroot/etc/
[root@ns2 etc]# cp named.rfc1912.zones  named.conf
[root@ns2 etc]# chown root:named named.conf
[root@ns2 etc]# chmod 777 named.conf

Now Create A Link into /etc directory of named.conf then edit.

[root@ns2 etc]# ln –s /var/named/chroot/etc/named.conf  /etc/named.conf
[root@ns2 ~]# vi /etc/named.conf

Original 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
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
     type hint;
     file "named.ca";
};

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

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

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

zone "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.ip6.local";
     allow-update { none; };
};

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

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

Modified 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
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {

     directory "/var/named";

};

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

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

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

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

zone "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.ip6.local";
     allow-update { none; };
};

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

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

zone "alphabd.net" IN {
     type slave;
     file "alphabd.fz";
     masters { 210.207.201.1; };

};

zone "201.207.210.in-addr.arpa" IN {
     type slave;
     file "alphabd.rz";
     masters { 210.207.201.1; };
};

Step-6:  Now change the ownership & permission of  named directory

[root@ns2 ~]# chown root:named /var/named/chroot/var/named/
[root@ns2 named]# chmod 777 /var/named/chroot/var/named/

Step-7:  Edit the resolv.conf file by following this command

[root@ns2 named]# vi /etc/resolv.conf

search alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.2

Step-8:  Start the named service, that it will automatically copy the forward & reverse lookup zone file    from Primary DNS server.

[root@ns2 ~]# service iptables stop
[root@ns2 ~]# service network restart
[root@ns2 ~]# chkconfig named on
[root@ns2 ~]# service named restart

Step-9: Check the DNS server by following this command. Also check the Primary DNS from          secondary DNS.

[root@ns2 ~]# host 210.207.201.2
[root@ns2 ~]# host ns2.alphabd.net
[root@ns2 ~]# Ping ns2.alphabd.net
[root@ns2 ~]# nslookup ns2.alphabd.net
[root@ns2 ~]# nslookup 210.207.201.2
[root@ns2 ~]# dig ns2.alphabd.net
[root@ns2 ~]# dig –x 210.207.201.2
[root@ns2 ~]# dig –x ns2.alphabd.net
[root@ns2 ~]# dig –t SOA alphabd.net
[root@ns2 ~]# dig –t axfr alphabd.net

0 comments:

Post a Comment