Neuronvm bread crumb arrow icon Docs bread crumb arrow icon How to Setup and Configure a DNS Server on CentOS

How to Setup and Configure a DNS Server on CentOS

How to Setup and Configure a DNS Server on CentOS
Nicol.G
10m
0 comments
Print
2025/11/12

Working with the DNS system usually seems simple, but behind this simplicity lies a network of connections and processes that, if not configured correctly, can disrupt the entire service. The main role of DNS is to convert a familiar name into a numerical address. But its importance is not limited to this translation. Network security. Response speed. And service stability also depend on proper DNS configuration. In this guide, we will review the steps to set up a DNS Server on CentOS Server along with an explanation of why each step is necessary so that your structure is not only feasible but also reliable.

Getting to know the DNS Server on CentOS

CentOS is one of the most stable Linux distributions, and for this reason many network administrators rely on it to run sensitive services. DNS on CentOS is implemented with the help of the BIND service. But what is less discussed is the difference between the default settings and the actual needs of the network. Many users just open the file and activate it without paying attention to the role of each section. In this text, we have tried to explain each section along with its purpose.

Prerequisites before installation

To have a stable functioning DNS Server on CentOS, you need to prepare three parts from the beginning.

  • Updated CentOS system.
  • Root or sudo access.
  • Basic knowledge of network structure such as A, PTR, and NS records.

These are simple things, but ignoring them can cause runtime errors. Especially when DNS records are not properly synchronized with the internal network.

Step One. System Update

Out-of-date packages can cause inconsistencies in the execution of BIND. The following command prepares the system.

sudo yum update

This step is not just a routine task. In many cases, updating also fixes errors that were not discovered in previous versions. Something that is very important for a DNS Server on CentOS.

Step Two. Installing BIND

Using the following command, the main DNS service is installed.

sudo yum install bind bind-utils

The bind utils help you perform more thorough testing, especially when your records are newly created.

Step Three. Initial BIND Configuration

The main configuration file is located at:

/etc/named.conf

Opening this file, you will notice that its structure consists of several key sections. The options section determines which port and path the service uses for its files. If your server has multiple network cards, it is best to configure the listen on section carefully, as incorrect responses can lead to unwanted information disclosure. This is not mentioned in many guides, but it makes a big difference in real-world environments.

An example of a basic configuration is as follows.

options {
listen-on port 53 { any; };
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";
};

Next, the root zone and additional files are loaded.

zone "." IN {
type hint;
file "named.ca";
};

include "/etc/named.rfc1912.zones";

This structure helps BIND to coordinate with the DNS root servers.

Step Four. Creating Forward and Reverse Zones

In this section, users usually create and save only one file, but if the time and serial number in the SOA record are not set accurately, other servers will not recognize the new record. As a result, your changes will appear to be made, but in practice they will be ineffective.

Creating the Basic Zone

The following example is the basic structure of a zone.

$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2022103001
3600
1800
604800
86400
)
@ IN NS ns1.example.com.
@ IN A 192.168.1.1
ns1 IN A 192.168.1.1

To avoid errors, it is better to always set the SOA counter to the current date so that the version of the records can be identified.

Create a reverse zone

The reverse zone plays an important role in server reliability. Many email services reject connections if the PTR record is missing. An example of its route in CentOS would be:

/var/named/1.168.192.in-addr.arpa.zone

This zone must be consistent with the internal network and using the wrong address will cause long-term errors.

Step Five. Testing DNS Server Performance on CentOS

You can use the dig command to test. This tool not only displays the result, but also the response time and query path. This information is very helpful in troubleshooting.

dig example.com

If the record is returned correctly, it means that the files were loaded correctly.

Step Six. Enabling Access Through the Firewall

DNS uses port 53. To enable it, you need the following commands.

sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd --reload

If you are in a network with multiple layers of security, it is better to open DNS access only for the required IP range. This will prevent reflection attacks.

Common Errors When Running DNS

In many networks, A and MX records are created without coordination with the Reverse section. This causes inconsistencies in service authentication.

Another mistake is choosing serial numbers without considering the chronological order. This mistake causes secondary servers to ignore new records.

Sometimes the name server setting in the domain panel does not match the actual server. This error causes your records to not be updated from the end user’s perspective.

Conclusion

Setting up a DNS Server on CentOS is not just about installing and creating a few files. Each step has a specific reason and if ignored can cause network disruption. By following this guide, you will not only get your DNS service up and running, but you will also gain a better understanding of how it behaves. This knowledge will help you make future changes with more confidence. It is also a good idea to back up your zone files regularly. This will come in handy when a small error affects your entire domain name structure.

Share this Post
How useful was this post for you?
0 Points from 0 votes
Frequently Asked Questions

CentOS is one of the best options for running sensitive services like DNS due to its high stability and similarity to enterprise standards. Its updates are predictable and most tools are fully compatible with it.

The forward zone converts the domain name to IP, but the reverse zone verifies the identity of the server. Many services such as email and enterprise access will reject the request without a valid PTR. The absence of a reverse zone causes a trust error.

You can use the dig tool on an external server. If the correct record is answered and there are no unusual response times, the service is working properly. Otherwise, the firewall or zone configuration section should be checked.

Nicol.G

Leave a reply

Calculate the value of (9 - 3) :

Save my name and email in this browser for the next time.

Last Comments

Show More
© Copyright 2025 NeuronVM.
Use of this Site is subject to express terms of use