How to setup Master DNS server 

Core files for DNS
------

DNS deamon is called named.
Config file of dns ( bind ) is /etc/named.conf

DNS Database files are located in /var/named.
/etc/resolv.conf is the host look up file for DNS

Install the DNS packages
[root@dnsslave thomasa]# yum install bind bind-utils .


vi /etc/named.conf and edit the yellow one with network address 
options {
        listen-on port 53 { 127.0.0.1; 172.23.1.0/24; };
        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; 172.23.1.0/24; };

Towards the bottom of the /etc/named.conf add the forward and reverse lookup as shown fwd.chinchu.local.db is my forward lookup zone and reverse look up zone is 1.23.172 zone "chinchu.local" IN { type master; file "fwd.chinchu.local.db"; allow-update { none; }; }; zone "1.23.172.in-addr.arpa" IN { type master; file "1.23.172.db"; allow-update { none; }; }; These two db files need to be created in /default location /var/named or it can be any other location. You need to change the ownership of the file from root to named as shown
root@dns1 named]# ls -l total 36 -rw-r-----. 1 root named 457 Feb 27 21:14 1.23.172.db -rw-r-----. 1 root root 399 Feb 27 20:57 1.23.172.db.bak drwxrwx---. 2 named named 23 Feb 27 20:51 data drwxrwx---. 2 named named 31 Feb 27 20:59 dynamic -rw-r-----. 1 root named 564 Feb 27 21:13 fwd.chinchu.local.db -rw-r-----. 1 root root 513 Feb 27 20:57 fwd.chinchu.local.db.bak -rw-r-----. 1 root named 2281 May 22 2017 named.ca -rw-r-----. 1 root root 2036 Feb 27 20:57 named.conf.bak -rw-r-----. 1 root named 152 Dec 15 2009 named.empty -rw-r-----. 1 root named 152 Jun 21 2007 named.localhost -rw-r-----. 1 root named 168 Dec 15 2009 named.loopback drwxrwx---. 2 named named 6 Jan 29 17:23 slaves Sample of fwd.chinchu.local.db [root@dns1 named]# cat fwd.chinchu.local.db $TTL 86400 @ IN SOA dns1.chinchu.local. root.chinchu.local. ( 2014112511 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) ;Name Server Information @ IN NS dns1.chinchu.local. ;IP address of Name Server dns1 IN A 172.23.1.212 ;Mail exchanger chinchu.local. IN MX 10 mail.chinchu.local. ;A – Record HostName To Ip Address www IN A 172.23.1.120 mail IN A 172.23.1.121 oracle1 IN A 172.23.1.230 oracle2 IN A 172.23.1.231 nfsserver IN A 172.23.1.226 ;CNAME record ftp IN CNAME www.chinchu.local

Sample of 1.23.172.db reverse file
[root@dns1 named]# cat 1.23.172.db $TTL 86400 @ IN SOA dns1.chinchu.local. root.chinchu.local. ( 2014112511 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) ;Name Server Information @ IN NS dns1.chinchu.local. ;Reverse lookup for Name Server 212 IN PTR dns1.chinchu.local. ;PTR Record IP address to HostName 230 IN PTR oracle1.chinchu.local. 231 IN PTR oracle2.chinchu.local. 226 IN PTR nfsserver.chinchu.local. [root@dns1 named]# Go to /etc/resolv.conf and change name server to dns1.chinhcu.local

Restart the named service after this change and if everything is set well it should work well

service named restart or systemctl restart named

How to setup slave DNS server

Install the same bind and bind utils on a new server

vi /etc/named.conf and edit the yellow one with network address 
options {
        listen-on port 53 { 127.0.0.1; 172.23.1.0/24; };
        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; 172.23.1.0/24; };

Towards the bottom of the /etc/named.conf add the forward and reverse lookup as shown
fwd.chinchu.local.db is my forward lookup zone and reverse look up zone is 1.23.172 zone "chinchu.local" IN { type slave; file "slaves/fwd.chinchu.local.db"; allow-transfer { 172.23.1.0/24; }; masters { 172.23.1.212; }; }; zone "1.23.172.in-addr.arpa" IN { type slave; file "slaves/1.23.172.db"; allow-transfer { 172.23.1.0/24; }; masters { 172.23.1.212; }; };
Go to /etc/resolv.conf and change name server to dns2.chinhcu.local
Then create two empty files under /var/named/slaves and change owner to named as we did before. [root@dns2 slaves]# ls -ltr total 0 -rw-r--r--. 1 root named 0 Feb 27 21:31 fwd.chinchu.local.db -rw-r--r--. 1 root named 0 Feb 27 21:32 1.23.172.db
Restart DNS service
[root@dns2 slaves]# service named restart Redirecting to /bin/systemctl restart named.service when we restart the service we get two db’s as this and this replaces the two files created under the [root@dns2 slaves]# ls -ltr total 0 -rw-r--r--. 1 named root 0 Feb 27 21:31 db-g68j7p0i -rw-r--r--. 1 named root 0 Feb 27 21:32 db-F5aWpd2T That’s it and now you have a full functional DNS server

 
(Visited 89 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.

Leave a Reply