Configure a DNS Name Server on RHEL7/CentOS7

configure dns server on centos, installation and configuration of dns server, configuration of dns server in linux, dns server configuration in rhel7

Configure a DNS Name Server on RHEL7/CentOS7
This article is a quick step by step procedure for installation and configuration of Linux DNS Name server using bind on RHEL7/CentOS7.
Leave your comments if any and we appreciate your feedback.

What is DNS (Domain Name System) and Why do we use it?
DNS provides the resolution of hostnames to IP address and Vice versa.

When some one tries to access any websites or any servername, example www.learnitguide.net, request will go to the particular server by resolving the name www.learnitguide.net to the particular server ipaddress 192.168.2.10 as configured in DNS name server. This is called Forward zone name resolution. Same can be done in reverse way as IP Address 192.168.2.10 will resolve to the server name www.learnitguide.net, this is called Reverse zone name resolution.

Lab Server Setup:
Description Server Info Client Info
Operating System RHEL7 - 64 Bit RHEL7 - 64 Bit
Host Name linux1.learnitguide.net linux2.learnitguide.net
IP Address 192.168.2.10 192.168.2.20
Package Bind9 Not required
Service Name Named Not required

Server end configuration:

Step 1: Installing the DNS Packages bind
Install the appropriate DNS packages bind9 using yum to avoid dependencies issue. if yum is not configured, please refer the link http://www.learnitguide.net/2015/07/how-to-configure-local-yum-repo-server.html
[root@linux1 ~]# yum -y install bind*
Step 2: Edit the main configuration file.
Open the /etc/named.conf and append the below configuration.
zone "learnitguide.net" IN {
        type master;
        file "learnitguide.net.forward";
};
zone "2.168.192.in-addr.arpa" IN {
        type master;
        file "learnitguide.net.reverse";
};
This entries tells the DNS service which domains we are hosting here. The first zone statement for forward zone and the second zone statement for reverse zone. According to the file names, we have to create two zone files under /var/named/ which is given in detail in Step 3.
Change the below values in the same configuration file /etc/named.conf and save the changes, else your client will not able to listen or query.
listen-on port 53 { 127.0.0.1; };
allow-query     { localhost; };
to
listen-on port 53 { any; };
allow-query     { any; };
Verify the configuration file for any errors using the command named-checkconf
[root@linux1 ~]# named-checkconf
Step 3: Create a Forward and Reverse zone files
Now have to set up the two zone files as declared in the main configuration file /etc/named.conf to where its pointing to.

Go to the default zone files directory /var/named and create/copy the forward and reverse zone files.
[root@linux1 ~]# cd /var/named/
[root@linux1 named]# cp -rf named.localhost learnitguide.net.forward
[root@linux1 named]# cp -rf named.loopback learnitguide.net.reverse
Change the ownership of the files as "root:named".
[root@linux1 named]# chown root:named learnitguide.net.*
Edit the learnitguide.net.forward file for forward zone and add the client servers name, here we add only one node linux2 for testing.
[root@linux1 named]# vi learnitguide.net.forward
$TTL 1D
@       IN SOA  @ root.learnitguide.net. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       192.168.2.10
linux1  A       192.168.2.10
linux2  A       192.168.2.20
Edit the learnitguide.net.forward file for forward zone and add the client servers ip address last digit number, here we add only one node "20" for testing.
[root@linux1 named]# vi learnitguide.net.reverse
$TTL 1D
@       IN SOA  @ root.learnitguide.net. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       192.168.2.10
10      PTR     linux1
20      PTR     linux2
Step 4: Start the DNS service and check the status for any errors
[root@linux1 named]# systemctl start named
[root@linux1 named]# systemctl status named
named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled)
   Active: active (running) since Mon 2015-11-02 11:34:46 EST; 3s ago
  Process: 3059 ExecStart=/usr/sbin/named -u named $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 3058 ExecStartPre=/usr/sbin/named-checkconf -z /etc/named.conf (code=exited, status=0/SUCCESS)
 Main PID: 3062 (named)
   CGroup: /system.slice/named.service
           └─3062 /usr/sbin/named -u named
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone 0.in-addr.arpa/IN: loaded ...0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone 1.0.0.127.in-addr.arpa/IN:...0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0....0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone localhost/IN: loaded serial 0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone learnitguide.net/IN: loade...0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone 2.168.192.in-addr.arpa/IN:...0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: zone localhost.localdomain/IN: ...0
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: all zones loaded
Nov 02 11:34:46 linux1.learnitguide.net named[3062]: running
Nov 02 11:34:46 linux1.learnitguide.net systemd[1]: Started Berkeley Internet Name D....
Hint: Some lines were ellipsized, use -l to show in full.
[root@linux1 named]# 
Step 5: Verification of the name server resolution.
Use nslookup command to verify the resolution of each servers added in zone files.
[root@linux1 named]# nslookup linux1.learnitguide.net
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: linux1.learnitguide.net
Address: 192.168.2.10
[root@linux1 named]# nslookup linux2.learnitguide.net
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: linux2.learnitguide.net
Address: 192.168.2.20
That's it for server end configuration. Lets do it on client end.
Client end configuration:
Step 1: Edit the resolution file /etc/resolv.conf and add the domain, name server details as below
domain learnitguide.net
nameserver 192.168.2.10
Save and exit the file.
Step 2: Verification of the name server resolution.
[root@linux2 yum.repos.d]# nslookup linux1
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: linux1.learnitguide.net
Address: 192.168.2.10
[root@linux2 yum.repos.d]# nslookup linux2
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: linux2.learnitguide.net
Address: 192.168.2.20
That's all, we are able to resolve the server names from client successfully. Same way we have to add all our infrastructure servers in the zone files. dns server installation step by step, dns server installation in linux, how to create primary dns server and slave dns server, how to configure primary dns server, dns configuration linux, how to configure the dns server and client in linux, 
Leave your comments if any, we appreciate your feedback. configure dns server on linux, installation and configuration of dns server, installation and configuration of dns server in linux, configuration of dns server in linux, dns server installation and configuration in redhat linux step by step, dns server installation and configuration in rhel7 and centos7 linux, Install and Configure a DNS Name Server on RHEL7/CentOS7,
Subscribe us on youtube channel for practical video tutorials and follow us on social networking sites to not miss any updates. Step by Step DNS Name server, how to configure dns name server, Setting up Nameserver DNS using bind, Set Up a DNS Name Server, How To Install the BIND DNS Server on CentOS7, dns server installation and configuration, dns server installation in ubuntu, Step by Step dns configuration in rhel7, configure dns linux, dns Configuration, rhel7, rhel7 dns Configuration, Configuring the Network File System, Exporting a File System, Steps to configure a dns server on rhel7, dns in rhel7, Restart dns in centos7, centos7 dns share, centos7 dns export, centos7 dns mount, centos7 dns mount options, centos7 dns configuration
November 02, 2015

Post a Comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget