Monday, November 23, 2015

DNS configuration (RHEL 5)


Configuration steps of DNS server in RHEL 5:

Types of DNS:
1. Master DNS
2. Slave DNS
3. Forward DNS
4. Stealth Name Server

DNS lookup:
1. Forward lookup: System name to system IP resolution
2. Reverse Lookup: System IP to System name resolution

Packages required:
Bind (general package)
Bind-utils (client side)
Caching-nameserver (server side)
Bind-chroot (for security purpose, not recommended until configuration is done)


Steps:

1. #vim /etc/named.conf (have to create a new file):

Options {
directory “/var/named”;
};

Zone “example.com” {
Type master;
File forward_file;
};

Zone “1.168.192.in-addr.arpa” {
Type master;
File “reverse_file”;
};

Note: for convenience, a sample forward file is already saved in “/var/named/localhost.zone” and a sample file is “/var/named/named.local”. You can copy this forward file to the your new file name i.e. forward_file in “/var/named” directory.

Copy the files:
# cp /var/named/localhost.zone /var/named/forward_file
# cp /var/named/named.local /var/named/reverse_file


Change group and permissions of the newly created files:
# chgrp named forward_file
# chgrp named reverse_file

And
# chmod 640 forward_file
# chmod 640 reverse_file

Now, You can do changes in the “forward_file” according to your needs:
A sample forward file look like this:

example.com.  360      IN        NS       server.example.com.
Server              360      IN        A          192.168.1.14
system1            360      IN        A          192.168.1.15
system2            360      IN        A          192.168.1.16
and so on, depending on your systems.

Explanation:
1st column: you write here the name of the system but not with the domain name.
Example: if hostname of the system is “system1.example.com”, you will write here only “system1”, not “system1.example.com”.
2nd column: 360 means the time. Means, server will keep the info of the system for 360 seconds.
3rd Columns: IN means a class, Internet class.
4th column : NS means Name Server. In 1st line, You are giving the name of the DNS server, that’s why you are using NS here.

Note: in “forward” type file, you use “A” class, in reverse type of file, you use “PTR” class.
5th column: You write here the respective system IP address.

Note: in 1st line of the file, in 1st column, you write here the “domain name” which is “example.com”.
And in 4th column, you write, the FQDN (fully qualified domain name) of the server system which is “server.example.com”

Note: DO NOT FORGET TO ADD AN EXTRA DOT(.) IN THE END OF THE DOMAIN NAME AND THE HOSTNAME OF THE SERVER SYSTEM.

A sample reverse file look like this:
            IN        NS       server.example.com.
14        IN        PTR     server.example.com.
15        IN        PTR     system1.example.com.
16        IN        PTR     system2.example.com.
And so on according to your systems.

Explanation:
1st column: you write systems IP here. But only the host bit of the whole IP.
Example: system IP is 192.168.1.14. Then you need to write here only “14”. If your IP is of 2nd class 172.168.1.14, you will write here “14.1”.
2nd column is again IN (internet) class. You have to mention it.
3rd column: Again, NS (name server) and the PTR for the reverse file entries.
4th column: FQDN of the system.

Note: DO NOT FORGET TO ADD AN EXTRA DOT(.) IN THE END OF THE DOMAIN NAME AND THE HOSTNAME OF THE SERVER SYSTEM.

Note: In the 1st column, 1st line, nothing is mentioned here. There should be the IP range of the network, but it takes that from the “reverse” file name, so don’t need to mention it. You can leave it blank.

Now start the service:
# service named restart

Note: In my case, my DNS server is running on the IP “192.168.1.14”

To lookup the systems, run the command:
# nslookup station1.example.com 192.168.1.14

It will show the IP of the system which would be 192.168.1.15. This info would come from the server 192.168.1.14.
And
# nslookup 192.168.1.15 192.168.1.14

It will show the hostname of the system which is “system1.example.com”.

Note: You need to give the system hostname or the IP of the system you want to lookup and then you give the IP of the server system.

It is always not necessary to give the server IP in the command. For this, you need to do the entry of your DNS server in the configuration file “/etc/resolve.conf”

Write here your DNS server IP. Now you don’t need to give server IP in command.

No comments:

Post a Comment