Tuesday, December 27, 2011

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


Primary DNS Server Configuration

Step- 1: Check bind and caching-nameserver rpm package is installed or not by following this command:
                       
[root@ns1 ~]# rpm -qa | grep –i bind*    or
[root@ns1 ~]#  rpm –qa bind*            (if installed then it will show all the bind related packages)

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@ns1 ~]# rpm -qa caching-nameserver* 

Caching-nameserver-9.3.6-4.P1.el5

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

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

Step-2: Check and Configure the Network Card:

[root@ns1 ~]# 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.1
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@ns1 ~]# ifdown eth0
[root@ns1 ~]# ifup eth0
[root@ns1 ~]# service network restart

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

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

(Original File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ns1

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

[root@ns1 ~]# 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

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

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

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

[root@ns1 etc]# ln –s /var/named/chroot/etc/named.conf  /etc/named.conf
[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.
//
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 master;
     file "alphabd.fz";

};

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

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

[root@ns1 ~]# cd /var/named/chroot/var/named/
[root@ns1 named]# cp localhost.zone alphabd.fz
[root@ns1 named]# chown root:named alphabd.fz
[root@ns1 named]# chmod 777 alphabd.fz
[root@ns1 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     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

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

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

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.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.

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

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

search alphabd.net
nameserver 210.207.201.1

Step-9:    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.net   /var/named/chroot/var/named/
alphabd.rz


Step-10: DNS check

[root@ns1 ~]# service iptables stop
[root@ns1 ~]# service network restart
[root@ns1 ~]# chkconfig named on
[root@ns1 ~]# service named restart/status/start/stop/configtest
[root@ns1 ~]# host 210.207.201.1
[root@ns1 ~]# host ns1.alphabd.net
[root@ns1 ~]# Ping ns1.alphabd.net
[root@ns1 ~]# nslookup ns1.alphabd.net
[root@ns1 ~]# nslookup 210.207.201.1
[root@ns1 ~]# dig ns1.alphabd.net
[root@ns1 ~]# dig –x 210.207.201.1
[root@ns1 ~]# dig –x ns1.alphabd.net
[root@ns1 ~]# dig –t SOA alphabd.net
[root@ns1 ~]# dig –t axfr alphabd.net

7 comments:

  1. i'm type host 192.168.56.200 when reply this error message
    Host 200.56.168.192.in-addr.arpa not found: 2(SERVFAIL)
    how can i solve it ?

    ReplyDelete
  2. Mr. Ye Zeiya Shein See the related articale think you find your answer

    ReplyDelete
  3. when I restart dns service ... error msg display
    "BAD ZONE"

    ReplyDelete