Tuesday, December 27, 2011

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


SUB DNS Server Configuration

Change in Primary DNS Server:

Step-1:  Edit Forward Lookup zone file for SUB 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.
mail.alphabd.net.          IN NS      ns3.mail.alphabd.net.
ns1      IN A       210.207.201.1
ns2        IN A       210.207.201.2
www        IN CNAME   ns1.alphabd.net.
ns3.mail.alphabd.net. IN A 210.207.201.3

Esc → Shift + : → x! → Enter

 Step-2:  Edit Reverse Lookup zone file for Sub 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.
             IN NS         ns2.alphabd.net.
1          IN PTR        ns1.alphabd.net.
2            IN PTR        ns2.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.
mail.alphabd.net.    IN NS ns3.mail.alphabd.net.
1        IN PTR          ns1.alphabd.net.
2          IN PTR          ns2.alphabd.net.
3          IN PTR          ns3.mail.alphabd.net.

Step-3:    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-4:  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 Sub 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@ns3 ~]# rpm -qa | grep –i bind*    or
[root@ns3 ~]#  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@ns3 ~]# rpm -qa caching-nameserver*  

Caching-nameserver-9.3.6-4.P1.el5

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

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

Step-2: Check and Configure the Network Card:

[root@ns3 ~]# 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.3
NETMASK=255.255.255.0
NETWORK=210.207.201.0
BROADCAST=210.207.201.255

Press Esc → Shift + : → x! → Enter (For Save and Exit the Vi Editor).

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

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

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

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

(Original File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ns3
Press Esc → Shift + : → x! → Enter

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

[root@ns3 ~]# 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.3           ns3.mail.alphabd.net    ns3

Esc → Shift + : → x! → Enter

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

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

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

[root@ns3 etc]# ln –s /var/named/chroot/etc/named.conf  /etc/named.conf
[root@ns3 ~]# 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 "mail.alphabd.net" IN {
     type master;
     file "alphabd.fz";
};

zone "201.207.210.in-addr.arpa" IN {
     type master;
     file "alphabd.rz";
};
Esc → Shift + : → x! → Enter

Step-6:  copy, rename & change the ownership & permission of  localhost.zone file  for Forward                                   lookup zone.

[root@ns3 ~]# cd /var/named/chroot/var/named/
[root@ns3 named]# cp localhost.zone  alphabd.fz
[root@ns3 named]# chown root:named  alphabd.fz
[root@ns3 named]# chmod 777  alphabd.fz
[root@ns3 named]# vi alphabd.fz

Original File:  localhost.zone

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

           IN NS @
          IN A       127.0.0.1
           IN AAAA         ::1

Modified File:  alphabd.fz

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

           IN NS     ns3.mail.alphabd.net.
ns3      IN A       192.168.163.102
www        IN CNAME   ns3

Esc → Shift + : → x! → Enter

Step-7: copy & rename the  alphabd.fz  file  to alphabd.rz for Reverse lookup zone.

[root@ns3 named]# cp alphabd.fz  alphabd.rz
[root@ns3 named]# vi alphabd.rz

Original File:  alphabd.fz

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

           IN NS     ns3.mail.alphabd.net.
ns3      IN A       210.207.201.3
www        IN CNAME   ns3

Modified File:  alphabd.rz

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

           IN NS     ns3.mail.alphabd.net.
3          IN PTR     ns3.mail.alphabd.net.
3          IN PTR     www.mail.alphabd.net.

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

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

search alphabd.net
search mail.alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.3
 
Esc → Shift + : → x! → Enter

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

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

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

[root@ns3 ~]# host 210.207.201.3
[root@ns3 ~]# host ns3.mail.alphabd.net
[root@ns3 ~]# Ping ns3.mail.alphabd.net
[root@ns3 ~]# nslookup ns3.mail.alphabd.net
[root@ns3 ~]# nslookup 210.207.201.3
[root@ns3 ~]# dig ns3.mail.alphabd.net
[root@ns3 ~]# dig –x 210.207.201.3
[root@ns3 ~]# dig –x ns3.mail.alphabd.net
[root@ns3 ~]# dig –t SOA ns3.mail.alphabd.net
[root@ns3 ~]# dig –t axfr ns3.mail.alphabd.net
nbsp;

1 comments:

  1. thank you this awesome article.
    I am sharing this article in tuts publication network -> http://tutpub.com/

    ReplyDelete