How to Install and configure DNS on Ubuntu 20.04.

A DNS server is a system server that check a database of Ip address and clients.  It provides to resolve those names to public ip address as requested. DNS servers run software and communicate with each other using protocols.

Domain Name Service (DNS) is an Internet service that contains IP addresses and fully qualified domain names (FQDN) to other. Computers that run DNS are called name servers.

Install DNS

Update the System

apt-get update

Install the required packages

apt-get install -y bind9 bind9utils bind9-doc dnsutils

Start & Stop bind9 service

systemctl start bind9
systemctl stop bind9

Check Bind9 status

systemctl status bind9

Here is the command output.

Fig 1


Configure DNS Server

  • Go to DNS server main directory.
cd /etc/bind
  • At bind directory, we have Two zone file: one is global DNS conf file named.conf & second is local DNS config file named.conf.local.
  • We needs to create forward and reverse zones.
  • Open named.conf.local file.
vim named.conf.local
  • To create a zone & add the following values for forward zone.
zone "zone-name.local" IN { // Domain name
      type master; // Primary DNS

     file "/etc/bind/"; // Forward lookup file

     allow-update { none; }; // Since this is the primary DNS, it should be none.


  • Now Add the following value in same file for reverse zone.If network is, the name will be reversed as in 10.16.198
zone "" IN { //Reverse lookup name, should match your network in reverse order

     type master; // Primary DNS

     file "/etc/bind/"; //Reverse lookup file

     allow-update { none; }; //Since this is the primary DNS, it should be none.




Configure Bind DNS zone lookup files

  • DNS records for Both forward & Reverse zone are under zone lookup files.
  • Configure Forward zone lookup file.
  • Copy the db.local file to a  /etc/bind/ file.
cp /etc/bind/db.local /etc/bind/
  • Open the /etc/bind/ & mention the following lines.
$TTL    604800
@       IN      SOA (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;@      IN      NS      localhost.
;@      IN      A
;@      IN      AAAA    ::1

;Name Server Information

@        IN      NS

;IP address of Name Server

ns1     IN      A       ip-address

;Mail Exchanger

zone-name.local.   IN     MX   10

;A – Record HostName To Ip Address

www     IN       A      ip-address1
mail    IN       A      ip-address2

;CNAME record

ftp     IN      CNAME



  • SOA – Start of Authority.
  • NS – Name Server.
  • A – A record.
  • MX – Mail for Exchange.
  • CN – Canonical Name.


  • Configure Reverse zone lookup file.
  • Copy db.127 to a reverse.computingforgeeks.local.db file.
cp /etc/bind/db.127 /etc/bind/
  • Open the /etc/bind/ & mention the following lines.
; BIND reverse data file for local loopback interface
$TTL    604800
@       IN      SOA    zone-name.local. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

;Name Server Information

@       IN      NS
ns1     IN      A       ip-address

;Reverse lookup for Name Server

2      IN      PTR

;PTR Record IP address to HostName

3     IN      PTR
4     IN      PTR



  • PTR – Pointer.
  • SOA – Start of Authority.

Restart & Enable BIND service.

systemctl restart bind9
systemctl enable bind9

Access DNS server

  • On client machine, change the DNS server to our deployed server. For example:
echo "nameserver" >> /etc/resolv.conf
  • Now run dig command.The dig command is used to get the information about a domain name such as DNS server, domain IP , MX records.
  • Check the reverse DNS.
dig -x ip-address


2 responses to “How to Install and configure DNS on Ubuntu 20.04.”

    • Gracias por la respuesta.
      Seguramente seguiremos publicando publicaciones.

      Si te gusta esta publicación, comparte también la misma en tu red.

Leave a Reply

Your email address will not be published.