Setup Bind DNS Server CentOS 7

DNS, stands for Domain Name System, translates hostnames or URLs into IP addresses. For example, if we type red.my.id 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 red.my.id to 104.xx.xx.xxx. 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             : dns01.dapur.my.id
IP Address           :

Domain name ex : dapur.my.id

Private Name Server
IPv4 Glue records for dapur.my.id
ns1.dapur.my.id.	43200	IN	A
ns2.dapur.my.id.	43200	IN	A

There are no IPv6 Glue records for dapur.my.id
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/named.run";
                severity dynamic;

zone "dapur.my.id" {
                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      ns1.dapur.my.id. root.dapur.my.id.(
                                2019100914      ;Serial
                                3600            ;Refresh
                                1800            ;Retry
                                604800          ;Expire
                                86400           ;Minimum TTL

@       IN      NS      ns1.dapur.my.id.
@       IN      NS      ns2.dapur.my.id.

@       IN      A
ns1     IN      A
ns2     IN      A

www     IN      CNAME   dapur.my.id.

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 dapur.my.id /var/named/dapur.fwd

Sample output:

zone dapur.my.id/IN: loaded serial 2019100914

Start DNS server

systemctl start named
systemctl enable named
systemctl status named

Test DNS Server

dig dapur.my.id

Sample output:

[root@dns01 ~]# dig dapur.my.id

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> dapur.my.id
;; 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
;dapur.my.id.                   IN      A

dapur.my.id.            86400   IN      A

;; Query time: 3 msec
;; WHEN: Wed Oct 09 12:06:56 WIB 2019
;; MSG SIZE  rcvd: 56
nslookup dapur.my.id

Sample output:


Non-authoritative answer:
Name:   dapur.my.id

To make sure DNS is resolved, you can use a website like https://intodns.com or https://whatsmydns.com.