Sharing Ilmu

Sharing for useful things

How To Install and Configure DNS Server on Linux Centos 7

DNS Server is the service that used for domain translation server for translate the domain become ip address and vice versa. In this tutorial I’ll discuss about how to DNS server configuration on linux Centos 7.  For this article I’ll use ip address 10.100.1.1 for the dns server network 10.100.1.0/24 for client network.

First make sure you have configured network on your server and make sure your server already connected to the internet.

update your system first :

[root@DNSServer ~]# yum update

Install dns server packages :

[root@DNSServer ~]# yum install bind bind-utils -y

 

Edit the configuration zone at /etc/named.conf

[root@DNSServer ~]# vi /etc/named.conf
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

options {
                    listen-on port 53 { 127.0.0.1; 10.100.1.1; };
                    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";
                    recursing-file "/var/named/data/named.recursing";
                    secroots-file "/var/named/data/named.secroots";
                    allow-query { localhost; 10.100.1.0/24; };
                    allow-transfer { localhost; 10.100.1.0/24; };

Add the forwarding zone configuration  and reverse zone configuration in the named.conf at bellow section :

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

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

zone "1.100.10.in-addr.arpa" IN {
           type master;
           file "/var/named/db.100.10";
           allow-update { none; };
};

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

 

Edit Forward zone configuration file :

[root@DNSServer ~]# vi /var/named/db.taufiknurhuda

Add the following configuration :

;
$TTL 604800
@       IN      SOA       ns.taufiknurhuda.com. root.taufiknurhuda.com. (
                                  1          ;  Serial
                              604800         ;  Refresh
                               86400         ; Retry
                             2419200         ; Expire
                              604800 )       ; Negative Cache TTL
;
@       IN          NS            ns.taufiknurhuda.com.
@       IN          A             10.100.1.1
ns      IN          A             10.100.1.1
www     IN          A             10.100.1.1
mail    IN          A             10.100.1.1

 

Edit Reverse zone configuration file :

[root@DNSServer ~]# vi /var/named/db.100.10

Add the following configuration :

;
$TTL 604800
@    IN    SOA       ns.taufiknurhuda.com. root.taufiknurhuda.com. (
                                 1         ;  Serial
                            604800         ;  Refresh
                             86400         ; Retry
                           2419200         ; Expire
                            604800 )       ; Negative Cache TTL
;

;
@    IN    NS    ns.taufiknurhuda.com.
@    IN    PTR   taufiknurhuda.com.
1    IN    PTR   ns.taufiknurhuda.com.
1    IN    PTR   www.taufiknurhuda.com.
1    IN    PTR   mail.taufiknurhuda.com.

 

Test the configure named.conf with named-checkconf. If no error message appears, the configuration is success.

[root@DNSServer ~]# named-checkconf

Test the configure zone :

[root@DNSServer ~]# named-checkzone taufiknurhuda.web.id /var/named/db.taufiknurhuda
zone taufiknurhuda.web.id/IN: loaded serial 1
OK

[root@DNSServer ~]# named-checkzone 10.100.1.1 /var/named/db.100.10
zone 10.100.1.1/IN: loaded serial 1
OK

Add the firewalld configuration for dns service :

[root@DNSServer ~]# firewall-cmd --permanent --add-service=dns
success
[root@DNSServer ~]# firewall-cmd --reload
success

Restart Named service :

[root@DNSServer ~]# systemctl restart named

Configure resolv.conf

[root@DNSServer ~]# vi /etc/resolv.conf
   search taufiknurhuda.com
   nameserver 10.100.1.1
   nameserver 8.8.8.8

 

Then, test the configuration with nslookup :

[root@DNSServer ~]# nslookup taufiknurhuda.com
Server: 10.100.1.1
Address: 10.100.1.1#53

Name: taufiknurhuda.com
Address: 10.100.1.1

[root@DNSServer ~]# nslookup 10.100.1.1
1.1.100.10.in-addr.arpa name = mail.taufiknurhuda.com.
1.1.100.10.in-addr.arpa name = ns.taufiknurhuda.com.
1.1.100.10.in-addr.arpa name = www.taufiknurhuda.com.

 

Configuration is successfull.

 

z

Leave a Reply

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

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>