Saturday, January 9, 2010

Configure DNS in REDHAT Enterprise Linux 5 / CENTOS 5

Hi,

Here I have given easy step by step DNS configuration methods in Linux, I hope this will useful for you also.

1. First change or assign a host Name to your server; in this example my host Name is server.anand.com and my IP address is 192.168.50.196.

files /etc/hosts , /etc/sysconfig/network.
2. Download or Install following RPMS from CD/DVD of Linux OS.
RPMS :-
bind-utils-9.3.4-10.P1.el5

bind-sdb-9.3.4-10.P1.el5

bind-libs-9.3.4-10.P1.el5

bind-9.3.4-10.P1.el5

system-config-bind-4.0.3-4.el5.centos

bind-chroot-9.3.4-10.P1.el5

bind-libbind-devel-9.3.4-10.P1.el5

bind-devel-9.3.4-10.P1.el5

caching-nameserver-9.3.4-10.P1.el5


3. My DNS server IP address is 192.168.50.196

# cd /var/named/chroot/etc

copy file named.caching-nameserver.conf to named.conf

# cp named.caching-nameserver.conf named.conf

Make the following changes (It's require).

options {

listen-on port 53 { 127.0.0.1; 192.168.50.196; };

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

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

memstatistics-file "/var/named/data/named_mem_stats.txt";

query-source port 53;

query-source-v6 port 53;

allow-query { 127.0.0.1; 192.168.50.0/24; };

allow-transfer { 127.0.0.1; 192.168.50.196; };

forwarders { 127.0.0.1; 192.168.50.196; };

forward only;

};

logging {

channel default_debug {

file "data/named.run";

severity dynamic;

};

};

view localhost_resolver {

match-clients { localhost; 192.168.50.0/24; };

match-destinations { localhost; 192.168.50.0/24; };

recursion yes;

include "/etc/named.rfc1912.zones";

};

Save this file and exit

4. Save this file and exit

copy named.conf file to /etc directory.

# cp /var/named/chroot/etc/named.conf /etc/

5. # cd /etc

6. Open /etc/named.rfc1912.zones

zone "anand.com" IN {

type master;

file "anand.zone";

allow-update { none; };

allow-query { any; };

};


zone "50.168.192.in-addr.arpa" IN {

type master;

file "anand.local";

allow-update { none; };

allow-query { any; };

};

7. cd /var/named/chroot/var/named

8. cp localhost.zone anand.zone
9. cp named.local anand.local
10. Edit anand.zone and make the following changes.


$TTL 86400

@ IN SOA server.anand.com. root.server.anand.com. (

42 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

@ IN NS server.anand.com.

server.anand.com. IN A 192.168.50.196

ldaplinux.anand.com. IN A 192.168.50.115 # Client

myclient-no1 IN A 192.168.50.141 # Client

www IN CNAME server.anand.com.

ftp IN CNAME server.anand.com.

Save this file and exit


11. Edit anand.local and make the following changes

$TTL 86400

@ IN SOA server.anand.com. root.server.anand.com. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

@ IN NS server.anand.com.

196 IN PTR server.anand.com.

115 IN PTR ldaplinux.anand.com. # Client

141 IN PTR myclient-no1. # Client


Save this file and exit.

12. chown root:named anand.zone Permission 775
13. chown root:named anand.local Permission 775
14. chown root:named /var/named/chroot/etc/named.conf permission 775
15. chown root:named /etc/named.conf permission 775
16. chown root:named /etc/named.rfc1912.zones permission 775 This file link with /var/named/chroot/etc/named.rfc1912.zones

On Final DNS server.

# service named start
# chkconfig named on

To check DNS configuration is correct or wrong use following command.

# dig anand.com or dig -x 192.168.50.196

Here I am using dig -x 192.168.50.196

dig -x 192.168.50.196

; <<>> DiG 9.3.4-P1 <<>> -x 192.168.50.196

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29928

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:

;196.50.168.192.in-addr.arpa. IN PTR

;; ANSWER SECTION:

196.50.168.192.in-addr.arpa. 86400 IN PTR server.anand.com.

;; AUTHORITY SECTION:

50.168.192.in-addr.arpa. 86400 IN NS server.anand.com.

;; ADDITIONAL SECTION:

server.anand.com. 86400 IN A 192.168.50.196

;; Query time: 11 msec

;; SERVER: 192.168.50.196#53(192.168.50.196)

;; WHEN: Sat Jan 9 20:29:30 2010

;; MSG SIZE rcvd: 105


QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

All the four sections means Query: 1, Answer: 1, Authority: 1, Additional: 1 .

If it is 0 then you have to check all steps again properly.

Client Configuration:-

1.

Edit file /etc/resolv.conf
2.

make the following changes

search anand.com

nameserver 192.168.50.196 # DNS server IP Address



I hope these all steps will help you to configure DNS.

Anand Mane.