Header Ads

How to Configure DNS Server in Linux CentOS 7

How to Configure DNS Server in Linux CentOS 7

A Domain Name System (DNS) is an essential component of any network as it helps to translate domain names into IP addresses. Configuring DNS on Linux CentOS 7 can be challenging for beginners, but this article will guide you through the process with step-by-step instructions.

Table of Contents

  1. Prerequisites

  2. Install Bind Package

  3. Configure Bind Service

  4. Create Zone File

  5. Start Bind Service

  6. Verify DNS Resolution

  7. Additional Configuration Options


Before proceeding with the DNS configuration, ensure that your Linux CentOS 7 system is up-to-date by running the following command:
sudo yum update

You also need to have root or sudo access to your system.

Install Bind Package:

The first step in configuring a DNS server is to install the Bind package. Run the following command to install Bind:
sudo yum install bind bind-utils

Configure Bind Service:

After installing the Bind package, you need to configure the Bind service. Open the named.conf file using your favorite text editor:
sudo vi /etc/named.conf

Add the following line at the end of the file to define the local domain zone:

zone "example.com" IN {
type master;
file "/var/named/example.com.zone";
allow-update { none; };

Note: Replace example.com with your actual domain name.

Create Zone File:

After defining the local domain zone, you need to create the zone file. Run the following command to create the zone file:
sudo vi /var/named/example.com.zone

Add the following lines to the file to define the domain name and IP address mapping:

$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2016042201 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL

@ IN NS ns1.example.com.
@ IN A
ns1 IN A

Note: Replace with your server's IP address.

Start Bind Service:

After creating the zone file, start the Bind service by running the following command:
sudo systemctl start named

To enable the Bind service to start automatically at boot time, run the following command:

sudo systemctl enable named

Verify DNS Resolution:

To verify that your DNS server is working correctly, use the dig command to query the DNS server:
dig example.com

You should see the IP address of your server in the output.

Additional Configuration Options:

There are several additional configuration options that you can add to your DNS server configuration, such as configuring DNS forwarders, setting up DNSSEC, and configuring reverse DNS lookup. You can find more information about these options in the Bind documentation.

Configuring a DNS server on Linux CentOS 7 may seem daunting at first, but by following the above steps, you can set up a functional DNS server in no time. Remember to update your DNS records regularly and back up your zone files to ensure your DNS server remains secure and reliable.

Related Searches and Questions asked:

  • How to Add CNAME Record to DNS in Linux
  • How to Configure DNS Server in Linux Ubuntu?
  • How to Configure DNS Server in Linux Step by Step?
  • How to Find All DNS Servers in Linux?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    Powered by Blogger.