Tutorial Setup private DNS server on centos 8/7

Setup private DNS server on centos 7

Learn how to Setup private DNS server on centos 8/7. Simply put, a Domain Name System (DNS) is a hierarchical distribution naming system for computers, services, or any resource connected to the Internet or private network that handles information about the various domains assigned to each website and company. Most importantly, it translates into a meaningful and human-friendly domain name and numeric identifier associated with network equipment in order to locate and address these devices around the world. In fact, the dns server connects the domain to a server. In this post, you will learn how to install a private dns server on Linux in the centos version 8 or 7 distribution. You can visit the packages available in Eldernode to purchase CentOS VPS server.

Setup private DNS server on centos 8/7

In the following, we will introduce you to the Setup private DNS server on centos 8 or centos 7 process. Suppose you have a server with IP and you also have a domain called The first step is to install the BIND package and then configure it. Finally create the Zone files. Follow us in the continuation of this tutorial.

Note: You must replace your IP address and website address with the instructions in this article.

Recommended Article: How to Install oVirt on CentOS 8

How to install BIND package on CentOS 8 or Centos 7

BIND stands for Berkeley Internet Name Domain, which is software that provides the ability to convert a domain name to an IP. To execute commands either to install BIND DNS Server on CentOS 7 or to configure BIND DNS Server on CentOS 8 or centos 7 you need root server access to be able to connect to your server using SSH. You can install BIND using the following command:

yum -y install bind bind-utils

How to configure BIND on CentOS 8 or centos 7

The bind file for the bind service is located at etc/named.conf/. Open the etc/named.conf/ file and put the following two command lines in comment mode:

# listen-on port 53 {; };
# listen-on-v6 port 53 {:: 1; };

Now you need to add your network in the line below. For example in the following command I have added This allows customers on the network to use DNS to translate the name to IP:

allow-query {localhost;; };

If you want to move all zones to the server (, add the following line: (Optional)

allow-transfer {; };

Learn how to create Zone files

In the following commands, we have written a zone for the domain, which is added to the named.conf file:

zone "" IN {  type master;  file "";  allow-update { none; };  };

The following example is a reverse entry in the named.conf file called the reverse zone:

zone "" IN {  type master;  file "12.168.192.db";  allow-update { none; };  };

In the example above: is the name of the reverse reference.

Master represents the primary dns.

12.168.192.db is a reverse lookup file.

allow-update: Since this is the original DNS, it should not have it, which is why we set it to none.

How to create a lookup file for a zone

Now it is time to create a lookup file for a zone. By default, lookup files in the zone are located in the var/named/ folder. So you need to create a zone file called fwd.eldernode.db for forward lookup in this folder.

Note that all domain names must end with a dot.

Here are some keywords specific to Zone Files:

A – A record
NS – Name Server  
MX – Mail for Exchange  
CNAME – Canonical Name

Well, open the created zone file using the following command:

vi /var/named/

Now enter the following content:

$TTL 86400  @   IN  SOA (  2014112511  ;Serial  3600        ;Refresh  1800        ;Retry  604800      ;Expire  86400       ;Minimum TTL  )  ;Name Server Information  @      IN  NS  ;IP address of Name Server  primary IN  A  ;Mail exchanger IN  MX 10  ;A - Record HostName To Ip Address  www     IN  A  mail    IN  A  ;CNAME record  ftp     IN CNAME

Create a “zone” file called 12.168.192.db for the “reverse zone” under the var/named/ folder. Also set a reverse pointer for the above zone:

PTR – Pointer  SOA – Start of Authority


# vi /var/named/12.168.192.db    $TTL 86400  @   IN  SOA (  2014112511  ;Serial  3600        ;Refresh  1800        ;Retry  604800      ;Expire  86400       ;Minimum TTL  )  ;Name Server Information  @ IN  NS  ;Reverse lookup for Name Server  8        IN  PTR  ;PTR Record IP address to HostName  100      IN  PTR  150      IN  PTR

After creating the zone files, restart the bind service again.

 systemctl restart named.service

You can also enable the service to start at startup using the following command:

 systemctl enable named.service

You were able to successfully install, configure and set up a dns server on centos 8/7. Now if you do it right, your domain will connect to the server.


BIND software is one of the default DNS software and of course the most popular software of this service, which is specifically for Unix/Linux operating systems. Its main functionality in DNS Server is to translate the domain name into an IP address. Installing and configuring BIND on Linux servers is one of the most important things in server configuration. In this article, we tried to teach you how to setup a private DNS server on centos 8 or centos 7.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day