Saturday, October 5, 2013

Setup DNS Server in RHEL 5


DNS Server Configuration
========================

-- To setup yum installer Follow this Post

1) Install the necessary rpm (bind packages)  which are required to configure DNS Server.


[root@standalone2 ~]# yum install -y *bind* caching-nameserver


2) Notedown the Public IP address of the Server.

[root@standalone2 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:86:F8:24
          inet addr:192.168.0.30  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe86:f824/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26338 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40786 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1764870 (1.6 MiB)  TX bytes:8763994 (8.3 MiB)


IP Address - 192.168.0.30

3) Modify the named.conf coniguration files

[root@standalone2 ~]# cd /var/named/chroot/etc/

[root@standalone2 etc]# ls -lrt
total 16
-rw-r----- 1 root named  955 Dec  2  2010 named.rfc1912.zones
-rw-r----- 1 root named 1230 Dec  2  2010 named.caching-nameserver.conf
-rw-r--r-- 1 root root  2819 Oct 13  2012 localtime
-rw-r----- 1 root named  113 Oct  4 21:52 rndc.key


[root@standalone2 etc]# cp named.caching-nameserver.conf named.conf

[root@standalone2 etc]# vi named.conf

# edit the named.conf file...


Modify the below lines...


Before Modification
===================

        listen-on port 53 { 127.0.0.1; };
        listen-on-v6 port 53 { ::1; };

        allow-query     { localhost; };
        allow-query-cache { localhost; };

        match-clients      { localhost; };
        match-destinations { localhost; };


After Modificaton
=================



        listen-on port 53 { 192.168.0.30; };
#       listen-on-v6 port 53 { ::1; };


        allow-query     { any; };
        allow-query-cache { any; };

        match-clients      { any; };
        match-destinations { 192.168.0.30; };



[root@standalone2 etc]# ls -lrt
total 20
-rw-r----- 1 root named  955 Dec  2  2010 named.rfc1912.zones
-rw-r----- 1 root named 1230 Dec  2  2010 named.caching-nameserver.conf
-rw-r--r-- 1 root root  2819 Oct 13  2012 localtime
-rw-r----- 1 root named  113 Oct  4 21:52 rndc.key
-rw-r----- 1 root root  1219 Oct  4 22:46 named.conf


4. Edit the zones files.


[root@standalone2 etc]# vi named.rfc1912.zones

# Now edit the zone file


Mofiy the below lines.


Before Modification.
====================


zone "localdomain" IN {
file "localdomain.zone";



zone "0.0.127.in-addr.arpa" IN {
file "named.local";



After Modification
===================

zone "manzoor.com" IN {
file "forward.zone";

zone "0.168.192.in-addr.arpa" IN {
file "reverse.zone";


[root@standalone2 etc]# chgrp named named.conf

[root@standalone2 etc]# ls -lrt
total 20
-rw-r----- 1 root named 1230 Dec  2  2010 named.caching-nameserver.conf
-rw-r--r-- 1 root root  2819 Oct 13  2012 localtime
-rw-r----- 1 root named  113 Oct  4 21:52 rndc.key
-rw-r----- 1 root named 1219 Oct  4 22:46 named.conf
-rw-r----- 1 root named  954 Oct  4 23:20 named.rfc1912.zones


[root@standalone2 etc]# cd /var/named/chroot/var/named

[root@standalone2 named]# ls -lrt
total 36
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
drwxrwx--- 2 named named 4096 Aug 25  2004 data
-rw-r----- 1 root  named  427 Dec  2  2010 named.zero
-rw-r----- 1 root  named  426 Dec  2  2010 named.local
-rw-r----- 1 root  named  424 Dec  2  2010 named.ip6.local
-rw-r----- 1 root  named 1892 Dec  2  2010 named.ca
-rw-r----- 1 root  named  427 Dec  2  2010 named.broadcast
-rw-r----- 1 root  named  195 Dec  2  2010 localhost.zone
-rw-r----- 1 root  named  198 Dec  2  2010 localdomain.zone


-- Before in the zone file we have changed the localdoamin.zone to forward.zone and named.local to reverse.zone
   so copy the below files with the mentioned name and edit it

[root@standalone2 named]# cp localdomain.zone forward.zone
[root@standalone2 named]# cp named.local reverse.zone


[root@standalone2 named]# vi forward.zone


# Whole file before modification.
================================

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



# whole file after modification.
================================

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


[root@standalone2 named]# vi reverse.zone

# Whole file before modification.
================================

$TTL    86400
@       IN      SOA     localhost. root.localhost.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS      localhost.
1       IN      PTR     localhost.


# whole file after modification.
================================

$TTL    86400
@       IN      SOA     standalone2.manzoor.com. root.standalone2.manzoor.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS      standalone2.manzoor.com.
30      IN      PTR     standalone2.manzoor.com.



-- in the above 30 is the last pointer in the ip address 192.168.0.30


-- Change the group of forward.zone and reverse.zone files to named group.

[root@standalone2 named]# chgrp named forward.zone
[root@standalone2 named]# chgrp named reverse.zone


[root@standalone2 named]# ls -lrt
total 44
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
drwxrwx--- 2 named named 4096 Aug 25  2004 data
-rw-r----- 1 root  named  427 Dec  2  2010 named.zero
-rw-r----- 1 root  named  426 Dec  2  2010 named.local
-rw-r----- 1 root  named  424 Dec  2  2010 named.ip6.local
-rw-r----- 1 root  named 1892 Dec  2  2010 named.ca
-rw-r----- 1 root  named  427 Dec  2  2010 named.broadcast
-rw-r----- 1 root  named  195 Dec  2  2010 localhost.zone
-rw-r----- 1 root  named  198 Dec  2  2010 localdomain.zone
-rw-r----- 1 root  named  258 Oct  4 23:25 forward.zone
-rw-r----- 1 root  named  482 Oct  4 23:28 reverse.zone


[root@standalone2 named]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
::1                     localhost6.localdomain6 localhost6
##################################################
#### Public ips #################################
192.168.0.30    standalone2.manzoor.com         standalone2



5) Edit the resolv.conf file modify the localdomain to your domain name
and the nameserver ip address to the public ip of this server.


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

# Edit file as per below details.


search manzoor.com
nameserver 192.168.0.30


-- Host name should be updated in network file as below

[root@standalone2 named]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=standalone2.manzoor.com


-- Restart the named service


[root@standalone2 named]# service named restart
Stopping named:                                            [  OK  ]
Starting named:                                            [  OK  ]

-- Test the dns

[root@standalone2 named]# dig standalone2.manzoor.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <<>> standalone2.manzoor.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- 6354="" id:="" noerror="" opcode:="" p="" query="" status:="">;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;standalone2.manzoor.com.       IN      A

;; ANSWER SECTION:
standalone2.manzoor.com. 86400  IN      A       192.168.0.30

;; AUTHORITY SECTION:
manzoor.com.            86400   IN      NS      standalone2.manzoor.com.

;; Query time: 4 msec
;; SERVER: 192.168.0.30#53(192.168.0.30)
;; WHEN: Fri Oct  4 23:32:47 2013
;; MSG SIZE  rcvd: 71


- We got the answer without error.

[root@standalone2 named]# nslookup standalone2.manzoor.com
Server:         192.168.0.30
Address:        192.168.0.30#53

Name:   standalone2.manzoor.com
Address: 192.168.0.30

[root@standalone2 named]# nslookup 192.168.0.30
Server:         192.168.0.30
Address:        192.168.0.30#53

30.0.168.192.in-addr.arpa       name = standalone2.manzoor.com.



== DNS Configuration for the server has been completed =====================

No comments:

Post a Comment