Thursday, June 19, 2014

Private DNS server setup on Linux

Hadoop cluster requires forward and reverse DNS lookup correctly for FQDN.
/etc/hosts can not help reverse lookup, so setting up your private DNS server is needed if you do not have corporate DNS server which can be used for this Hadoop Cluster.

Below steps are tested on CentOS 6.4.
Please note that, different platform/OS have different directories for configuration files.
Here are the current IP<->hostname mapping in this example, "hdm.xxx.com" is selected as my private DNS server:
192.168.192.100 admin.xxx.com
192.168.192.101 hdm.xxx.com
192.168.192.103 hdw1.xxx.com
192.168.192.102 hdw2.xxx.com
192.168.192.104 hdw3.xxx.com

1. Install below libraries on selected DNS server.

Note: Here I do not install "bind-chroot" package.
bind (includes DNS server, named)
bind-utils (utilities for querying DNS servers about host information)
bind-libs (libraries used by the bind server and utils package)
eg:
[root@hdm ~]# rpm -qa |grep ^bind
bind-9.8.2-0.23.rc1.el6_5.1.x86_64
bind-libs-9.8.2-0.23.rc1.el6_5.1.x86_64
bind-utils-9.8.2-0.23.rc1.el6_5.1.x86_64

2. Configure /etc/named.conf

2.1 Allow queries on any interface

listen-on port 53 { any; };

2.2 Forward Zone File References in named.conf

Point to your zone file named "hadoop.zone".
Here we only allow queries from 192.168.192.x network.
zone "xxx.com" {

   type master;
   notify no;
   allow-query { 192.168.192.1/24 };
   file "hadoop.zone";

};

2.3 Reverse Zone File References in named.conf

Point to your zone file named "192-168-192.zone" for 192.168.192.x network.
zone "192.168.192.in-addr.arpa" {
   type master;
   notify no;
   allow-query { any; };
   file "192-168-192.zone";
};

3. Configuring The Zone Files /var/named/hadoop.zone

$ORIGIN xxx.com.
$TTL 3D
@       IN      SOA     hdm.xxx.com. hostmaster.xxx.com. (
                       200211152       ; serial#
                       3600            ; refresh, seconds
                       3600            ; retry, seconds
                       3600            ; expire, seconds
                       3600 )          ; minimum, seconds

                NS      hdm             ; Inet Address of nameserver
  
localhost       A       127.0.0.1
admin           A       192.168.192.100
hdm             A       192.168.192.101
hdw1            A       192.168.192.103
hdw2            A       192.168.192.102
hdw3            A       192.168.192.104

4. Configuring Reverse Zone File /var/named/192-168-192.zone

$ORIGIN 192.168.192.in-addr.arpa. 
$TTL 3D
@       IN        SOA        hdm.xxx.com.  hostmaster.xxx.com. (
                            200303301          ; serial number
                            8H                 ; refresh, seconds
                            2H                 ; retry, seconds
                            4W                 ; expire, seconds
                            1D )               ; minimum, seconds

                  NS         hdm.xxx.com.   ; Nameserver Address

100                 PTR        admin.xxx.com.
101                 PTR        hdm.xxx.com.
102                 PTR        hdw2.xxx.com.
103                 PTR        hdw1.xxx.com.
104                 PTR        hdw3.xxx.com.

5. Start named

/etc/init.d/named start

6. Edit /etc/resolv.conf on this DNS server.

Add below entry as the first "nameserver" entry.
nameserver 127.0.0.1

7. Edit /etc/resolv.conf on other servers.

Add below entry as the first "nameserver" entry.
(192.168.192.101 is the IP of the DNS server.)
nameserver 192.168.192.101

8. Test 

[root@admin ~]# host hdm.xxx.com
hdm.xxx.com has address 192.168.192.101
[root@admin ~]# host 192.168.192.101
101.192.168.192.in-addr.arpa domain name pointer hdm.xxx.com.

9. Enable named to auto start on DNS server.

chkconfig named on

Refer to: <Quick HOWTO : Ch18 : Configuring DNS>

No comments:

Post a Comment

Popular Posts