Thursday, December 2, 2010

DNS [ Domain Name Server / System ]

           DNS [ Domain Name Server / System ] For RHEL 4

If we want to register multiple domains and wish to give same Ip address for those sites then DNS is used. If client user enters url names then DNS is used to understand that name and searches the particular Ip address of that site. It acts as a mediator between user and rest internet.

To check the rpm of DNS is installed or not give command :

rpm -qa | grep bind*

Here name of DNS service is “named” and package name is “bind
BIND : Berkely Internet Named Domain

edit “/etc/named.conf ” file. If this file is not there then move /etc/named.custom file to the same location with “named.conf” or copy it,

i.e. # cp /etc/named.custom /etc/named.conf

# vim /etc/named.conf

1) controls : from where this file gets modified.
2) Zone : the format of zone file is very important.

Zone “.” IN {
type hint;
file “named.ca” // the name of file containing zone records.
};
zone “localhost” IN {
type master;
file “localhost.zone”;
allow-update {none};
};

First two zones are called as Forward lookup zones. In that client give the name and dns server returns the Ip address for that name. After that the type come named “reverse lookup zone”. In that client give Ip address and the DNS server returns the DNS name of that Ip address.
i.e. 1) if in forward lookup zone the url is like “arpa.addr.in” then in reverse lookup zone it becomes “in.addr.arpa”
2) I fin forward lookup zone the Ip address is “192.168.100.10” then in reverse lookup zone it becomes “100.168.192.in.addr.arpa”. And the “.10” gets stored in records of RLZ.
3) Zone “0.0.127.in=addr.arpa” IN {
type master;
file “named.conf”;
allow-update { none; };
};
make changes as next line

zone “pranay.com” IN {
type master;
file “pranay.com.zone”;
allow-update { none; };
};

if this option is “none” and if the primary master gets off then no any client can update its record. If you are having secondary server then instead of “none” type your secondary server's Ip address.

Pranay.com.zone” file   (your zone file)

There are three files in “/var/named” directory, of that “named.local” file is of reverse zone. Copy “localhost.zone” file and paste it at same location with name “pranay.com.zone”.

Now edit “pranay.com.zone” file :

a) $TTL 86400 : if any client caches this file then he can cache it for 86400 seconds only. After that he needs to download it from server again.

b) $ORIGIN localhost.

Server's name
i.e. type $ORIGIN    (server's domain name) 

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


IN NS @               (Here IN is 'Internet' NS is 'Name server' & @ is your                                     machine)

  IN A                      (now delete this IN A and)

Make changes as

PRANAY(i.e. your domain name) IN A ipaddress
www IN A ipaddress
 another client IN  A   ipaddress


save & exit

Edit “/etc/hosts” file

only keep there below line,

127.0.0.1 localhost.localdomain localhost

 &    delete all next lines
save & exit
Then start service named i.e.
 

# service named start
# netconfig

set your ip address & set name server ip address i.e. dns server address
ok

# service network restart

To check it type,
# ping www.pranay.com
It will ping the site.

To check whether server is ok & service is ok give command,

# nslookup pranay.pranay.com
# dig pranay.pranay.com



Edit “/var/named/pranay.com.zone” file

make changes as

IN SOA . root

And

  IN NS     (server's ip adress)



And
$ORIGIN pranay.com                 (i.e. name of your zone)

save & exit

Then Give Command :

# dig pranay.pranay.com

Then,

# ping pranay.pranay.com

Now
Check the entries in “/etc/hosts” file
# vim /etc/httpd/conf/httpd.conf

Make changes as

NameVirtualHost (ip address of server):80

Then changs as
(VirtualHost www.pranay1.com)

(VirtualHost www.pranay.com) 



then change as

ServerName (ip address of server):80

save & Exit

# service httpd restart


TO PING LINUX DNS SERVER FROM WINDOWS XP MACHINE :

Goto XP's My Network places properties → local area connection properties → TCP-IP properties → Give DNS server IP address → ok

goto run
cmd
 ping   (server's Ip address)  
ping pranay.pranay.com
ping PRANAY.pranay.com
nslookup pranay.pranay.com

it will show IP address.

                                        IMPORTANT
1) If you want to create a new zone then copy file “/etc/named/localhost.zone” to the same location with your zone name. i.e. web.com.zone
2) Edit file “/etc/httpd/conf/httpd.conf” and make changes as given above
3) Edit “web.com.zone” file and make changes as given above
4) edit “/etc/named.conf” and make changes as given above
5) restart services named and httpd

Creating Secondary Master

1) Edit “/etc/named.conf

zone “abc.com” IN {
type slave ;
file “abc.com.zone” ;
  master {(ip address) ;} ;
} ;


If you want to allow your zone to somebody else then,

zone “web.com.zone” IN {
type master ;
file “web.com.zone” ;
allow-update {(ip address of that machine) ;} ;
} ;


save & exit

Now Edit “/etc/rndc.key” file
This file contains security key. This security key is unique for each computer. We need to generate & specify this key for each computer.

Edit “/etc/rndc.conf” file

make change at the end of this file as :

 
server (ip address)   {
key “redhat” ;
} ;

include “/etc/rndc.key” ;

save & exit

OR

edit “/etc/named.conf ” file

add # to lines with key word “control” and also to nest 2 lines
add # to last line with ley word “include”

save & exit

No comments:

Post a Comment