🌐How to Install and Configure a Domain Name Server (DNS)

Good to know : What is DNS and real world examples

A DNS server is a server that is used to translate IP addresses into host names so that they are more efficient and easy to remember. Apart from that, DNS is used to identify computers, services, and other resources that can be reached via the Internet or other Internet Protocol (IP) networks.

A simple example of implementing DNS, for example, is when you want to access a website like Google. By configuring the DNS server, you only need to type the address google.com, and not the IP 216.239.38.120, but you can still access the IP above to display pages from google.com.


Configuration

Install Package

apt install bind9 dnsutils -y

Copy File

Copy the db.local (File Forward) and db.127 (File Reverse) files into a new file. This is so that if there is a config error later, we still have a backup file.

cp /etc/bind/db.local /etc/bind/db.rizwan
cp /etc/bind/db.127 /etc/bind/db.10.1.31

Information :

  • File Forward functions for conversion from DNS to IP Address.

  • Meanwhile, the Reverse File functions to convert IP Address to DNS.

Edit File

nano /etc/bind/db.rizwan
nano /etc/bind/db.10.1.31
nano /etc/bind/named.conf.default-zones
nano /etc/resolv.conf
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     rizwanpemula.com. root.rizwanpemula.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      rizwanpemula.com.
@       IN      A       10.1.31.1
@       IN      MX 0    10.1.31.1
mail    IN      A       10.1.31.1
www     IN      A       10.1.31.1
php     IN      A       10.1.31.1
wordpress       IN      A       10.1.31.1
phpmyadmin      IN      A       10.1.31.1

Edit files one by one !!!

Restart Service

/etc/init.d/bind9 restart

Configuration is Completed

Check DNS Name

nslookup <domain>
nslookup rizwanpemula.com

Last updated