INSTALLATION OF DNS

INSTALLATION OF DNS ON RED HAT LINUX 8

PREREQUISITE:

STEP 1: CHANGING HOSTNAME

hostnamectl set-hostname primary-dns.kaushal.local
reboot

redhat-dns

hostnamectl

redhat-dns

STEP 2: INSTALLING DNS PACKAGE

dnf install bind bind-utils -y

redhat-dns

systemctl start named
systemctl enable named
systemctl status named

redhat-dns

STEP 3: SET STATIC IP ADDRESS

redhat-dns

redhat-dns

redhat-dns

redhat-dns

redhat-dns

redhat-dns

systemctl restart NetworkManager
ifconfig

redhat-dns

STEP 4: COLLECTING INFORMATION ABOUT THE SYSTEM

ifconfig

redhat-dns

hostname

redhat-dns

Machine IP 192.168.56.200
hostname (FQDN) primary-dns.kaushal.local
Network Address 192.168.56.0/24

STEP 5: Configure bind DNS server

cp /etc/named.conf  /etc/named.bak
nano /etc/named.conf

redhat-dns

// listen-on port 53 { 127.0.0.1; }; 
// listen-on-v6 port 53 { ::1; };
allow-query { localhost; 192.168.56.0/24; };

redhat-dns

//forward zone
zone "kaushal.local" IN {
     type master;
     file "kaushal.local.db";
     allow-update { none; };
     allow-query { any; };
};

//backward zone
zone "56.168.192.in-addr.arpa" IN {
     type master;
     file "kaushal.local.rev";
     allow-update { none; };
     allow-query { any; };
};

redhat-dns

named-checkconf

redhat-dns

STEP 6: Create a forward DNS zone file for the domain

nano /var/named/kaushal.local.db

redhat-dns

$TTL 86400
@ IN SOA primary-dns.kaushal.local. admin.kaushal.local. (
                                                2020011800 ;Serial
                                                3600 ;Refresh
                                                1800 ;Retry
                                                604800 ;Expire
                                                86400 ;Minimum TTL
)

;Name Server Information
@ IN NS primary-dns.kaushal.local.

;IP Address for Name Server
primary-dns IN A 192.168.56.200

;A Record for the following Host name
www  IN   A   192.168.56.200
test  IN   A   192.168.56.201

;CNAME Record
ftp  IN   CNAME www.kaushal.local.

redhat-dns

named-checkzone kaushal.local /var/named/kaushal.local.db

redhat-dns

STEP 7: Create a reverse DNS zone file for the domain

nano /var/named/kaushal.local.rev

redhat-dns

$TTL 86400
@ IN SOA primary-dns.kaushal.local. admin.kaushal.local. (
                                            2020011800 ;Serial
                                            3600 ;Refresh
                                            1800 ;Retry
                                            604800 ;Expire
                                            86400 ;Minimum TTL
)
;Name Server Information
@ IN NS primary-dns.kaushal.local.
primary-dns     IN      A       192.168.56.200

;Reverse lookup for Name Server
200 IN PTR primary-dns.kaushal.local.

;PTR Record IP address to Hostname
200     IN      PTR     www.kaushal.local
201     IN      PTR     test.kaushal.local

redhat-dns

named-checkzone 192.168.56.200 /var/named/kaushal.local.rev

redhat-dns

STEP 8: assign the necessary file permissions to the two configuration files.

chown named:named /var/named/kaushal.local.db
chown named:named /var/named/kaushal.local.rev

redhat-dns

systemctl restart named

redhat-dns

STEP 9: Add Firewall Rule

firewall-cmd --add-service=dns --zone=public --permanent
firewall-cmd --reload

redhat-dns

STEP 10: Test the Bind DNS server from a client system

For linux client machine:

sudo nano /etc/resov.conf

redhat-dns

nameserver 192.168.56.200

redhat-dns

Using the nslookup command test the Bind DNS server as shown:

nslookup primary-dns.kaushal.local
nslookup 192.168.56.200

redhat-dns

nslookup www.kaushal.local
nslookup test.kaushal.local

redhat-dns

Perfect! The reverse DNS lookup is also working as we would expect. 🥳

For Windows client machine:

redhat-dns

redhat-dns

redhat-dns

redhat-dns

Using the nslookup command test the Bind DNS server as shown:

nslookup primary-dns.kaushal.local
nslookup 192.168.56.200

redhat-dns

nslookup www.kaushal.local
nslookup test.kaushal.local

redhat-dns

Perfect! The reverse DNS lookup is also working as we would expect. 🥳

redhat-dns