How to Install and Configure DNS Server on Ubuntu

how to install and configure dns server on ubuntu

Domain Name System (DNS) is a system that combines human-readable domain names with IP addresses, which allows users to effortlessly navigate the Internet or even their own private network. DNS is essential in private networks because it allows devices connected to the network to talk to one another using names, not IP addresses.

Setting up your network using completely qualified domain names rather than IP addresses will make it much easier to set up and manage your applications and services. Installing the personal DNS server will improve the management of your network more efficiently.

The proper setup of a Domain Name System (DNS) is a crucial aspect of managing servers and their infrastructure because it permits you to quickly search for network interfaces and IP addresses using names. Once you buy Linux VPS hosting account, you may ask yourself how to configure the DNS server in Ubuntu 20.04. What is the Ubuntu 20.04 set DNS server command line?

In this guide, we’ll cover how to set up a DNS server on Ubuntu 22.04 and where the DNS configuration file is in Linux. This guide can be used for earlier versions of Ubuntu and a variety of other Linux distros that are built on Ubuntu, like Linux Mint or Pop! OS.

 

Install DNS Server Software

BIND (Berkeley Internet Name Domain) is a full software package that includes the most popular DNS (Domain Name System) server software. The most current significant version, called BIND 9, was first released in 2000 and is maintained regularly with the help of the Internet Systems Consortium.

Bind9 is the name given to the package to refer to the DNS server running on Ubuntu and is included in the repository that is the base. Installing bind9 is the first step you need to complete to establish the DNS servers of your choice. Follow the below procedure to set up bind9 as well as its dependencies. Once you buy a Linux server, you need to install this package on your server in order to set up a DNS server on Ubuntu 22.04.

sudo apt install -y bind9 bind9utils bind9-doc dnsutils

 

Configure DNS Server on Ubuntu

The Ubuntu change DNS server command line can be used to configure a DNS on Ubuntu, but first, you need to install Bind9 as mentioned above. Bind9 keeps its configuration data as well as zone lookup settings in the  /etc/bind which is the DNS configuration file in Linux. You should use the /etc/bind/named.conf.local file to store your local DNS zone information, rather than using the global /etc/bind/named.conf file.

DNS zones give you a particular zone to manage and define DNS records. Since all of our domains will be part of the linuxpip.local domain, we’ll be using that for our forwarding zone. The following commands can be used to modify the configuration of your zone.

sudo nano /etc/bind/named.conf.local

We’ll have to add a forward zone as well as a reverse zone in the file. What’s inside the files must appear like this.

 

zone “linuxpip.local” IN { // Domain name

   type master; // Primary DNS

  file “/etc/bind/forward.linuxpip.local.db”; // Forward lookup file

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

};

zone “0.168.192.in-addr.arpa” IN { //Reverse lookup name, should match your network in reverse order

  type master; // Primary DNS

  file “/etc/bind/reverse.linuxpip.local.db”; //Reverse lookup file

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

};

 

The first block represents the configuration for a forward zone. The second one is the reverse zone.

 

Primary Master

In a master server primary configuration, the DNS obtains the data for the zone from a file that is kept in its server. In addition, the DNS holds control of the zone. If we now have a domain named “example.com” we are going to change the DNS to serve as the primary master of that domain.

Forward Zone File

In the forward zone, the name will be mapped on the IP.

 

Step 1: Edit and open your /etc/bind/named.conf file.

sudo vi /etc/bind/named.conf

 

Make sure it has the following lines and is not commented:

include “/etc/bind/named.conf.options”;

include “/etc/bind/named.conf.local”;

include “/etc/bind/named.conf.default-zones”;

 

Step 2: Open and edit the /etc/bind/named.conf.local file to add a DNS zone.

 

sudo vi /etc/bind/named.conf.local

Attach the next block:

area “example.com” {

Type master;

file “/etc/bind/db.example.com”;

};

 

Step 3: Create a zone document using the template.

sudo cp /etc/bind/db.local /etc/bind/db.example.com

Step 4: Then, open the new zone file.

sudo vi /etc/bind/db.example.com

 

It is important to note that you need to increment the Serial Number each time you update your zone file.

Step 5: Restart DNS Service to apply the changes.

sudo systemctl restart bind9

Include one of the blocks below:

zone “10.0.2.in-addr.arpa” {

Type master;

File “/etc/bind/db.10”;

};

Configuration Files Verification

After completing the previous configurations, we must verify that each configuration is correct.

Step 1. Follow the steps below to determine if the system will show any errors.

named-checkzone example.com /etc/bind/db.example.com

named-checkzone 192.168.0.0/32 /etc/bind/db.10

named-checkconf  /etc/bind/named.conf.local

named-checkconf  /etc/bind/named.conf

 

It is possible that you have an alternative serial number, so don’t be concerned.

We have finally installed and set up our DNS servers on Ubuntu successfully. I hope you enjoy this tutorial, and should you have any queries, simply leave a message, and we’ll be happy to help.

 

Conclusion

In this guide, we tried to answer your questions on how to configure the DNS server in Ubuntu 18.04 step by step as well as how to configure the DNS server in Ubuntu 20.04 step by step. Configuration of DNS can be a crucial part of owning a Linux server. Once you buy Linux VPS hosting, configuring your DNS server must be the next step to take care of.

Leave a Reply

Your email address will not be published.