Setup Bind DNS Server CentOS 7

February 08, 2020

DNS, stands for Domain Name System, translates hostnames or URLs into IP addresses. For example, if we type in browser, the DNS server translates the domain name into its associated ip address. Since the IP addresses are hard to remember all time, DNS servers are used to translate the hostnames like to So it makes easy to remember the domain names instead of its IP address.

DNS Server

DNS Server Installation


Operating System

Operating System     : CentOS 7 minimal server
Hostname             :
IP Address           :

Domain name ex :

Private Name Server
IPv4 Glue records for	43200	IN	A	43200	IN	A

There are no IPv6 Glue records for
Install and configure Bind DNS Server
Install Bind DNS Server
yum update -y
yum install bind bind-utils -y

Configure Bind DNS Server

Edit file /etc/named.conf

mv /etc/named.conf /etc/named.conf-backup
vim /etc/named.conf

Add the following lines:

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

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

zone "" {
                type master;
                file "/var/named/dapur.fwd";

Create Zone file

Create forward and reverse zone files which we mentioned in the ''/etc/named.conf'' file.

Create DNS Zone

Create dapur.fwd file in the /var/named directory.

Add the following lines:

$TTL 86400
@       IN      SOA
                                2019100914      ;Serial
                                3600            ;Refresh
                                1800            ;Retry
                                604800          ;Expire
                                86400           ;Minimum TTL

@       IN      NS
@       IN      NS

@       IN      A
ns1     IN      A
ns2     IN      A

www     IN      CNAME

Check configuration file

Check DNS default configuration file:

named-checkconf /etc/named.conf

If it returns nothing, the configuration file is valid.

Check zone file:

named-checkzone /var/named/dapur.fwd

Sample output:

zone loaded serial 2019100914

Start DNS server

systemctl start named
systemctl enable named
systemctl status named

Test DNS Server


Sample output:

[root@dns01 ~]# dig

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16079
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;                   IN      A

;; ANSWER SECTION:            86400   IN      A

;; Query time: 3 msec
;; WHEN: Wed Oct 09 12:06:56 WIB 2019
;; MSG SIZE  rcvd: 56

Sample output:


Non-authoritative answer:

To make sure DNS is resolved, you can use a website like or