How to Setup DNS (Bind) Server on CentOS/RHEL

The Domain name system use to translate domain names to IP address and vice versa.For example when visitors go to your domain name like,“”, Our computer sends a request to DNS and get an IP address of domain.

In This article  we will help you to setup DNS server on CentOS and RedHat systems.

Install Bind Packages

To install package simple execute below command:

yum install bind bind-chroot

Edit Main Configuration File

Now we have to edit the main configuration file, Bind default configuration file is located under /etc directory. But in chroot environment this file is located at /var/named/chroot/etc directory. Now edit the file and update content as below.

Content for the named.conf file is as follows:

// /var/named/chroot/etc/named.conf
options {
        listen-on port 53 {;;; };
        listen-on-v6 port 53 { ::1; };
        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";
        allow-query     { localhost;;; };
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";

logging {
        channel default_debug {
                file "data/";
                severity dynamic;

zone "." IN {
        type hint;
        file "";

zone "" IN {
        type master;
        file "/var/named/";

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

Create Zone File for Your Domain

After creating bind configuration file, Now we have to create a zone file for your domain as per configuration, for example we are using in this article.

nano /var/named/chroot/var/named/

File content is as follows:

Zone file for
$TTL 14400
@      86400    IN      SOA (
                3013040200      ; serial, todays date+todays
                86400           ; refresh, seconds
                7200            ; retry, seconds
                3600000         ; expire, seconds
                86400          ; minimum, seconds
      ) 86400 IN NS 86400 IN NS IN A IN MX 0
mail 			  IN CNAME
www 			  IN CNAME

If you have more domains,You can create zone file for those domains individually.

Add More Domains

To add more domains in DNS, create zone files individually for all domain after that add an entry for all zones in named.conf like as above.

Start Bind Service

Start named service using following command:

service named restart

Now enable auto start on system boot:

chkconfig named on

Test Your DNS Setup

Now test your DNS server using below command:


So we have successfully set up a DNS server.