In this quick config we will setup the Berkeley Internet Name Domain (DNS) service named. First, let's briefly describe our environment and proposed scenario. We will be setting up a DNS server to host a single zone file for domain Our DNS server will act as a master authority for this domain and will resolve fully qualified domain (FQDN) and to an IP address

Furthermore, our named daemon will be listening on a two local IP addresses, the loopback IP address and local network interface Lastly, the DNS server will allow queries from any external IP address.

DNS server Installation

Now that we have described our basic scenario let's begin with an DNS server installation. To install DNS server on RHEL7 use yum command below:
# yum install bind
RHEL_7_Disc/productid                         | 1.6 kB     00:00     
  Verifying  : 32:bind-9.9.4-14.el7.x86_64                       1/2 
  Verifying  : 32:bind-libs-9.9.4-14.el7.x86_64                  2/2 

  bind.x86_64 32:9.9.4-14.el7                                        

Dependency Installed:
  bind-libs.x86_64 32:9.9.4-14.el7                                   

Once the DNS installation is finished we will now make a quick configuration to make named daemon listen on our loopback and local network interface address:
[root@rhel7 ~] # ip addr show | grep inet
    inet scope host lo
    inet6 ::1/128 scope host 
    inet brd scope global enp0s3
    inet6 fe80::a00:27ff:fe15:38b7/64 scope link

From the above command output we can see our both IPv4 and IPv6 IP addresses. Let's make our named daemon to listen on both. Open the main named configuration file /etc/named.conf and change line:

Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

listen-on port 53 {; };
listen-on port 53 {;; };
At this point we can start named daemon:
[root@rhel7 ~]# service named start
Redirecting to /bin/systemctl start  named.service
If the above servicecommand hangs make sure that you have a correctly setup your hostname and that you can resolve it:
[root@rhel7 ~]# ping -c 1 `hostname`
ping: unknown host rhel7
Quickest way to fix this is to edit your /etc/hosts file to something like:
[root@rhel7 ~]# vi /etc/hosts   rhel7 localhost localhost.localdomain localhost4 localhost4.localdomain4  rhel7
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@rhel7 ~]# ping -c 1 `hostname`
PING rhel7 ( 56(84) bytes of data.
64 bytes from rhel7 ( icmp_seq=1 ttl=64 time=0.080 ms

--- rhel7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.080/0.080/0.080/0.000 ms
At this point you should be able to start your DNS server without any problems. Once your named daemon started check port 53 by using a netstat command which is a part of net-tools package:
[root@rhel7 ~]# netstat -ant | grep -w 53
RHEL7 - Check named DNS port 53
At this point we should have DNS server configured to be listening on at least two sockets:

Firewall Settings

Now is the time to open a firewall to allow DNS queries from external sources. Make sure you have both protocols TCP and UDP:
[root@rhel7 ~]# firewall-cmd --zone=public --add-port=53/tcp --permanent
[root@rhel7 ~]# firewall-cmd --zone=public --add-port=53/udp --permanent
[root@rhel7 ~]# firewall-cmd --reload
Test that you can access port 53 from some other external host. The easiest way is to use nmap command:
[lrendek@localhost ~]$ nmap -p 53

Starting Nmap 6.45 ( ) at 2014-11-08 16:40 AEDT
Nmap scan report for rhel7.local (
Host is up (0.00040s latency).
53/tcp open  domain

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
As well as check whether DNS port 53 is accessible using UDP protocol. You will need root privileges for this:
# nmap -sU -p 53

Starting Nmap 6.45 ( ) at 2014-11-08 17:15 AEDT
Nmap scan report for rhel7.local (
Host is up (0.00044s latency).
53/udp open  domain
MAC Address: 08:00:27:15:38:B7 (Cadmus Computer Systems)

Nmap done: 1 IP address (1 host up) scanned in 0.51 seconds

Zone file configuration

All good. Now, it is time to define our zone file for domain. First we create a directory to host all our master zone files:
[root@rhel7 ~]# mkdir -p /etc/bind/zones/master/
Next, let's create the actual zone file with a following content: create a zone file:
[root@rhel7 ~]# vi /etc/bind/zones/master/
; BIND data file for
$TTL    3h
@       IN      SOA (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day

@       IN      NS      ns1.rhel7.local.
@       IN      NS      ns2.rhel7.local.    		IN      A
www 				IN      A
Change the above zone file to suit your environment, add MX records as well as change Name Server records ns1.rhel7.local. and ns2.rhel7.local. to your FQDN that your new DNS server can be resolved with eg. and Once ready include our new zone file to the named config file /etc/named.rfc1912.zones:
zone "" {
       type master;
       file "/etc/bind/zones/master/";
Restart your DNS server:
[root@rhel7 ~]# service named restart
Redirecting to /bin/systemctl restart  named.service

DNS server configuration

If there are no errors and the named daemon started correctly once again open the main named configuration file /etc/named.conf and change line:
allow-query     { localhost; };
allow-query     { any; };
The above will allow query your DNS server from external sources. Restart your named daemon :
[root@rhel7 ~]# service named restart
Redirecting to /bin/systemctl restart  named.service
As a last configuration step remains is to make sure that our DNS server starts after we reboot our RHEL7 linux server:
[root@rhel7 ~]# systemctl enable named
ln -s '/usr/lib/systemd/system/named.service' '/etc/systemd/system/'

RHEL 7 DNS Server Testing

At this stage you should be ready to ask your DNS server to resolve domain From some external host now try to query your DNS server for a domain using dig command:
[lrendek@localhost ~]$ dig @
Resolve domain name from using RHEL7 DNS server - named
All working as expected. The above config helped you to get started with some basic configuration of your DNS server on RHEL7 linux server.
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:

Comments and Discussions