Free Shipping

Secure Payment

easy returns

24/7 support

Configuring DNS Server on Linux

 July 9  | 0 Comments

DNS stands for Domain Name System (or Service or Server). It translates domain names into IP addresses. Generally, alphabetic domains are easier to remember, however, the Internet Service is based on IP addresses. So, every time we use domain name it gets translated to IP address.

For example, might translate to .

Before moving on to how to configure DNS, we should be aware of the following:

  1. What is DNS?
  2. How it works?

So, what is DNS and how does it work?

DNS (Domain Name System) is a system which resolve Name into their associated IP address and vice versa. DNS is the part of Application Layer in TCP/IP reference model.


When translating to their associated IP addresses, we get the result as When you type into your web browser’s address bar, your computer contacts your current DNS server and asks what IP address is associated with it.

DNS is implemented using two software components:

(a) DNS server

(b) DNS client (or resolver).

Both the components are run as background service applications.

Now, let’s try to understand what is a Domain.

Brief Introduction about Domains:

A Domain provides hierarchy property to any name. Some of the top level Domains are as follows:

  1. .com (for commercial use)
  2. .net (for network solution)
  3. .edu (for educational use)
  4. .org (for non-profit organization)
  5. .mil ( for military only)
  6. .gov ( for government use)
  7. .int ( International use )

DNS Server:

There are three types of zones (Database file). They are:

1) Forward Master Zone – Transfers name into IP.

2) Reverse Master Zone – Translates IP into name.

3) Slave Zone – Creates sub-domains.

Through DNS, you can create fully qualified Domain, Partially Qualified Domain Name or both.

Example:-   is a Fully Qualified Domain Name (FQDN) is Partially Qualified Domain Name (PQDN)

Note: DNS Server is also known as BIND (Berkley Internet Naming Daemon).


DNS Configuration in Centos 6.7 Linux:

As with any new server, it’s always important to ensure that your system is up to date. You can verify this by checking for updates using ‘yum’ as follows:

The all DNS configuration need root access, so use root instead of normal user! Appears abrupt

yum update –y


Steps to Configure DNS in Centos Linux:

Step 1: To Begin with, you need to install the BIND and BIND Utilities packages using the below command.

yum install bind*


Step 2: Modify the active Ethernet properties as shown below.

vi /etc/sysconfig/network-script/ifcfg-eth0


Step 3: Configure /etc/sysconfig/network file to add a hostname.

vi /etc/sysconfig/network


Step 4: Now, open BIND (named) configuration file.

vi  /etc/named.conf

Next, find the highlighted properties and modify it accordingly to your Linux Server networking shown in the below images.

Note: You need to scroll down further to add more properties.



Finally, save and exit the named.conf using esc + wq!

Step 5: Create the Forward and Reverse Zone files as mentioned in named.conf.

Configuring Forward Zone:

  1. a) Create a Forward Zone file under /var/named in the name of There are samples under the /var/named/ directory, just make a copy of that file and modify it as per your requirement.
cp /var/named/named.localhost  /var/named/
  1. b) Modify the file accordingly, as shown in the below screenshot.
vi  /var/named/

Configuring Reverse Zone:

Create a file for Reverse Zone under /var/named or directly copy the Forward Zone into /var/named/

cp /var/named/  /var/named/
vi  /var/named/

Now, add the properties into as shown in the below screenshot.


Now, the Forward and Reverse zones are configured.

Step 6: Change the group to named using below command.

As it is very important file to network it has to be isolated inside named directory.

chgrp named /var/named/
chgrp named /var/named/

Step 7: Change ownership of these zone files.

chown named:named /var/named/
chown named:named /var/named/

Step 8: We need to check for errors in the conf file and Zone file.

named-checkconf /etc/named.conf
named-checkzone  /var/named/

o/p => OK

named-checkzone  /var/named/

o/p=> OK

Step 9: Now, we can start named services.

service named start


Once the named service has started successfully, we need to ensure that it is enabled as a startup service, by running the following command.

chkconfig named on

Step 10: Make sure to add the iptables rules or (disable it [optional] )

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT
iptables -A INPUT -j DROP

You need to save the iptable and restart the iptables service using the below commands.

service iptables save
service iptables restart

Step 11: Check the DNS Server and the available host using dig and nslookup- command.



If you receive a response which includes an answer and authority section, then your Nameserver has been configured correctly.

The Master DNS has been configured Now.

In case of any queries related to this post, feel free to comment below or write to us at

Keep visiting our website Acadgild for more updates on Big Data and other technologies. Click here to learn Big Data Hadoop Development.