Friday, January 1, 2021

Domain Name System (DNS)

 


              DNS (Domain Naming System)


                                                                 


DNS stands for Domain Naming System. Domain is human readable name .DNS automatically converts the names  into IP address .It is search Public IP address at internet and  send the request on root domain .Root domain is decided the which type request and domain like .com ,.edu .gov .net .

Example :- we type  domain name in our Web browser  it is fetch  to the IP addresses of Web  servers hosting those sites.


(i) Install the packages bind, caching-name
for RHEL - 6 &bind, cashing-name and unbound
for RHEL - 7.

# yum install bind* caching-name* -y
(to install the DNS packages for RHEL - 6)

# yum install bind* caching-name* unbound* -y

(to install the DNS packages for RHEL - 7)

(ii)Change the hostname by adding fully qualified domain name and make it permanent.

# hostname <fully qualified domain name>

(to change the hostname in RHEL - 6)

# hostname server9.example.com

(example for setting hostname temporarily in RHEL - 6)

# hostnamectl set <fully qualified domain name>

(to change the hostname in RHEL - 7)

# hostnamectl set server9.example.com

(example for setting hostname temporarily in RHEL - 7)

# vim /etc/hosts

(open this file and go to last line and type as below in RHEL - 6 only)
<IP address> <fully qualified domain name>
<hostname>  172.25.9.11
server9.example.com
server9
(for example of the above syntax)
# vim /etc/sysconfig/network
(open this file and go to last line and type as below in
RHEL - 6 only)
HOSTNAME=<fully qualified domain name>
HOSTNAME=server9.example.com
(for example of the above syntax)

(ii)Open the DNS main configuration file by

# vim /etc/named.conf command.

* Go to line number 11 and edit this line as below.

listen-on port 53 { 127.0.0.1; <server IP address>; };

Example : listen-on port 53 {127.0.0.1; 172.25.9.11; };
* Go to line number 17 and edit this line as below.allow-query
{ localhost; <Network ID>/<netmask>; };
Example : allow-query
{localhost; 172.25.9.0/24; };
(save and exit this file)

(iii) Open the DNS zone reference file by
# vim /etc/named.rfc1912.zones command
* Go to line number 19 and copy 5 lines and paste them at last of the file.
zone "<domain name>" IN {
type-master;
file "<forward lookup zone file name>";
allow-update { none; };
};

 

Example : zone "example.com" IN {
type-master;
file "named.forward";
allow-update { none; };
};
* Go to line number 31 and copy 5 lines and paste them at last of the file.
zone "<Three octets of the DNS server IP address> . in . addr . arpa" IN {
type-master;
file "<reverse lookup zone file name>";
allow-update { none; };
};
Example : zone "9.25.172 . in . addr . arpa" IN {
type-master;
file "named.reverse";
allow-update { none; };
};
(save and exit this file)

(iv) Copy /var/named/named.localhost file to /var/named/named.forward and edit as follows.
# cp -p /var/named/named.localhost /var/named/named.forward
# vim /var/named/named.forward
* Go to line number 2 and edit as follows.


Example : The line number 2 should be edited as follows.
@
IN SOA server9.example.com. root.example.com. {
The line number 8 should be edited as follows.
NS
server9.example.com.     A             172.25.9.11
server9.example.com.     IN    A     172.25.9.11
client9.example.com.      IN    A     172.25.9.10
client10.example.com.    IN    A     172.25.9.12
client11.example.com.    IN    A     172.25.9.13
www                                IN   CNAME   server9.example.com.
(save and  exit this file)

(v) Copy /var/named/named.empty file to /var/named/named.reverse and edit as follows.
# cp -p /var/named/named.empty /var/named/named.reverse
# vim /var/named/named.reverse


Example : The line number 2 should be edited as follows.
@
IN SOA server9.example.com. root.example.com. {
The line number 8 should be edited as follows.
                     

                               NS                        server9.example.com   

                               11        IN PTR    server9.example.com
                               10        IN PTR    client9.example.com
                               12        IN PTR    client10.example.com
                               13        IN PTR    client11.example.com
                        server9.example.com   IN A        172.25.9.11
                        www        IN    CNAME    server9.example.com
 

    (save and   exit this file)

(v) Check the DNS  configuration files for syntax errors.
# named-checkconf /etc/named.conf
# named-checkconf /etc/named.rfc1912.zones
# name-checkzone <domain name><forward lookup zone>
 

Example : # named-checkzone example.com /var/named/named.forward
 

# named-checkzone <domain name><reverse lookup zone>
 

Example : # named-checkzone example.com /var/named/named.reverse
 

(vii) Give full permissions to the forward and reverse lookup zones.
 

# chmod 777 /var/named/named.forward
# chmod 777 /var/named/named.reverse
 

(viii) Open /etc/sysconfig/network-scripts/ifcfg-eth0 and enter the DNS domain details if not present.
 

# vim /etc/sysconfig/network-scripts/ifcfg-eth0
(go to last line and type as follows)
DNS 1=example.com
(save and exit this file)

(ix) Add the DNS server IP address in /etc/resolve.conf
# vim /etc/resolve.conf

Example :
 search          example.com 

nameserver   172.25.9.11
(save and exit this file)
(x)
 

Restart the DNS server deamons.
 

# service named restart

(x) Restart the DNS server deamons.
# service named restart   (to restart the deamon in RHEL - 6)
# chkconfig named on    (to enable the deamon at next boot time in RHEL - 6)
 

# systemctl restart named unbound
(to restart the deamons in RHEL -7)
 

# systemctl enable named unbound   (to enable the deamons at next
boot time in RHEL -7)
 

(xi) Add the DNS service to the IP tables and Firewall.
 

# setup    (then select the Firewall configuration option and add DNS in RHEL - 6)
 

# service iptables restart       (to restart the IP tables in RHEL - 6)
 

# service iptables save   (to save the IP tables in RHEL -6)


# firewall-cmd --permanent --add-service=dns (to add the DNS service to firewall in RHEL - 7)
# firewall-cmd --complete-reload
(to reload the firewall in RHEL - 7)

No comments:

Post a Comment