How to Install and Configure DNS on RHEL7

How to Install and Configure DNS on RHEL7

Domain name servers DNS or Nameserver, maps devices hostnames with their respective IP addresses, DNS is normally implemented using a central servers that is authoritative for a domain and refer to other DNS servers for other domains. There are four DNS server configuration types:


It has the authoritative zone records for the domain that act as DNS Server. Answers directly queries about the authoritative domain and forwards other domain queries to other DNS Servers.


Slave DNS server acts as an authoritative DNS server getting the zone records form the DNS master Server.


Caching-Only DNS Server is not authoritative for any zone, all queries are forwarded to other DNS Servers. If they are not stored in the DNS cache zone. Answers for all queries are cached in DNS cache zone for a time.


As caching-only DNS server, forwarding DNS is not authoritative for any zone, all queries are forwarded to a specific list of nameservers.

A nameserver can be master for some zones, slave for other and offer forwarding to others

Few Important DNS Records

A = IPv4 Address record

AAAA = IPv6 Address record
PTR = Pointer record
NS = Name service / server
MX = Mail Exchanger
SOA = State of Authority
CNAME =    Canonical name / Alias Name

Important Files and required package details

Packages Required   :  bind

Version    :  9

Daemon: named

Config Files:



 Default zone files location:


Port Number: 53

Step 1 : Installing

Let we install bind in the server, using yum

[root@Foxutech ~]# yum install bind* -y

Once packages successfully install, now let we start and enable the services, to start a service first we need start named-chroot before named.service because it will generate config files

[root@Foxutech ~]# systemctl enable named-chroot.service

[root@Foxutech ~]# systemctl start named-chroot.service

[root@Foxutech ~]# systemctl enable named.service

[root@Foxutech ~]# systemctl start named.service

Step 2: Configuration

Once package install and started successfully, now we need to change some fields in our configuration file,

[root@Foxutech ~]# vim /var/named/chroot/etc/named.conf

options {

listen-on port 53 {;; };

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”;

allow-query     { localhost;; };

Here just we need to add your server IP and networks details. Here we are installing and configuring Caching-only DNS Server, Allow query using for enable caching only.

Now edit zones configuration file, here we add domain details and our ip details

[root@Foxutech ~]# vim /var/named/chroot/etc/named.rfc1912.zones

zone “” IN {

        type master;

        file “”;

        allow-update { none; };


zone “” IN {

        type master;

        file “”;

        allow-update { none; };


#### Zoned Ended Here ####

zone “” IN {  here mention your domain name.

file “”;  mention forward zone filename(you can give any name)

zone “” IN { in this line write your IP address in reverse way

file “”; mention reverse zone filename(you can give any name)

Save configuration file and Exit

 Creating Zone files

Forward lookup zone – forward lookup zone will convert host name to IP address

Reverse lookup zone – reverse lookup zone will convert IP address to host name

Go to /var/named/chroot/var/named/

copy the files as per the file names which we have mentioned in above zones configuration file

in this example

named.local –>

named.loopback –>

[root@Foxutech named]# cd /var/named/chroot/var/named

[root@Foxutech named]# cp named.localhost

[root@Foxutech named]# cp named.loopback

[root@Foxutech named]# vim

$TTL   300

@               IN SOA (

43             ; serial (d. adams)

3H             ; refresh

15M             ; retry

1W             ; expiry

1D )           ; minimum

@       IN     NS

@               IN A 

mail           IN A 

ns1             IN A 

ns2             IN A 

Add NS record as DNS Server name and domain name (do not forgot to add (dot) yet end)

First A record will be your domain name and DNS server IP address

[root@Foxutech named]# vim

$TTL   86400

@       IN     SOA (

1997022700 ; Serial

28800     ; Refresh

14400     ; Retry

3600000   ; Expire

86400 )   ; Minimum

IN     NS

IN     NS

25     IN     PTR

Note: don’t miss any single (dot) which makes problem while start named service

Step 3: Permission and Restart the Service

Once changes has been done, make sure configuration file contains necessary permission

[root@Foxutech named]# chown root:named

[root@Foxutech named]# chown root:named

Add firewall rule to communicate DNS port out

[root@Foxutech ~]# firewall-cmd –permanent –add-service=dns


[root@Foxutech ~]# firewall-cmd –reload


Now restart your named service.

[root@Foxutech named]# systemctl restart named.service

[root@Foxutech named]# systemctl status named.service

Step 4: Configure DNS in Client

In Client machine, add master DNS details in /ets/resolv.conf

[root@Foxutech named]# vim /etc/resolve.conf




Step 5; Verify DNS

To Verify DNS, we can use nslookup and dig. Make sure its resolving.

# nslookup



#dig -x