Get 50% Discount Offer 7 Days

NeuronVM

Contact Info

Chicago 12, Melborne City, USA

+88 01682648101

[email protected]

A Step by Step Guide to Setting up a DNS Server on CentOs
0
(0)

Domain name system or DNS is responsible for translating hostnames or URLs to IP addresses. For example, if you enter www.neuronvm.com in the browser, the DNS server will translate the domain name to its associated IP address. But due to the difficulty of remembering the IP address, you can use DNS servers to translate the hostname as xxx.xxx.xx.xxx. In other words, a domain name is easier to remember than an IP address. Here, you will learn how to setting up a DNS server on CentOS.

6 Steps to Setup a DNS Server on CentOS

Setting up a DNS server on CentOS from Linux VPS involves a few steps. In this example, we will use three nodes to start our tutorial. Then, we will guide you through the process of setting up a DNS server using BIND (Berkeley Internet Name Domain), which is a widely used DNS server software on Linux. So keep going!

6 Steps to Setup a DNS Server on CentOS

Requirements

If you want to have a successful installation, you should prepare some requirements:

  • An up-to-date Linux CentOS distribution
  • Access with sudo or root privileges

Step 1: Update your CentOS Server

Before you start configuring DNS, you need to ensure that your Centos Linux VPS system is up to date. For this purpose, use the following command:

sudo yum update

Step 2: Install BIND DNS Server

If you want to configure a DNS server, you must use Bind, and in this section, we will show how to install it by running the following command:

sudo yum install bind bind-utils

Step 3: Configure the DNS Server

Edit the BIND configuration file, typically located at /etc/named.conf or /etc/named/named.conf. You can use your preferred text editor (e.g., nano, vim, or gedit).

sudo nano /etc/named.conf

Here’s a basic configuration example:

conf

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";
};

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

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

This configuration sets up the DNS server to listen on port 53, which is the default DNS port. Make sure to replace /var/named with the appropriate directory for your configuration and zone files.

Step 4: Configure Forward and Reverse DNS Zone Files

Zone files define the DNS records for your domain. You need at least two types of zone files: a forward lookup zone and a reverse lookup zone. Create these zone files under the appropriate directory (e.g., /var/named):

1- Forward Lookup Zone File (example.com):

Create a file named example.com.zone (replace “example.com” with your domain name) and define the DNS records within it. Here’s a basic example:

conf

$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2022103001 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)
@ IN NS ns1.example.com.
@ IN A 192.168.1.1
ns1 IN A 192.168.1.1

2- Reverse Lookup Zone File (1.168.192.in-addr.arpa):

Create a file named 1.168.192.in-addr.arpa.zone (replace “1.168.192” with the reverse of your network IP) and define the reverse DNS records.

Step 5: Verify DNS Configuration

It is time to verify the DNS configuration. So, use tools like dig or nslookup to test your DNS server. For example:

dig example.com

Step 6: Configure Firewall (Optional)

Open port 53 in your firewall to allow DNS traffic. On CentOS 7 or 8, you can use the following commands:

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

Tip: Replace “example.com” and IP addresses with your actual domain and network information.

Troubleshooting Some Issues About Setup DNS

Here are some common issues to setup DNS server:

1- If DNS records are setup incorrectly, it can result in websites not resolving or emails not being delivered.

Solution:

Double-check your DNS records. Ensure that A, CNAME, MX, and other records are configured correctly. Use online DNS checkers to validate your DNS setup.

2- Incorrect or outdated name server settings can lead to DNS failures.

Solution:

Verify that your domain registrar has the correct name servers configured. Ensure they match the name servers you’ve set up for your domain.

Conclusion

That’s a basic setup for a DNS server on CentOS using Bind. DNS server configuration may seem complicated at first, but the steps mentioned in this article will help you set up the DNS server you need in the shortest possible time. Note that you should update DNS records regularly and back up zone files. Happy coding!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *