How to configure Ubuntu DNS Server

DNS is abbreviated as Domain Name System. As we know that the computer is a machine which only understands the binary or we can make it easy by saying it understands the machine code. Now we have different websites having alphabetical names. For example we have facebook.com, google.com. In actuality these alphabetical names are for the better understanding for human beings, for machines it is not addressable. So for this purpose there are some servers that assign different numerical base addresses against these alphabetical addresses so it can be recognized by the machine. Such servers which are responsible for assigning addresses are known as DNS (Domain name servers).

In this article we are going to discuss the different methods in Ubuntu for the DNS server configuration.

How we can do the DNS server configuration in the Ubuntu

We will discuss the method to configure the DNS server by opening a terminal and running a few commands:

DNS Server Configuration through the Ubuntu terminal

We can also configure the DNS through the terminal. For this purpose, first open the terminal by pressing CTRL + ALT + T. Before the installation process we will update our repository:

$ sudo apt update

Now we will install the DNS server by using the command bind9:

$ sudo apt install bind9

Next step is to install the utilities of the DNS by using the command of “dnsutils”:

$ sudo apt install dnsutils

Now to configure the DNS, we will first go to the address /etc/bind/named.conf.options and add the Google DNS for just understanding. We will add the following text by opening the address in the nano editor.

$ sudo nano /etc/bind/named.conf.options

Replace the following text in the editor, is Google’s DNS:

forwarders {;


Now quit after saving it and enable the new configuration by restarting the DNS using the systemctl command.

$ sudo systemctl restart bind9

Check the status of bind9

$ sudo systemctl status bind9

As the bind9 is running now we will test the domain which we edit in the configuration file as:

$ dig google.com

The output is showing it is the domain of Google and it runs successfully.

Now we will do primary zone configuration but before configuration lets have an idea what is going on. We stored some files at some host and in this configuration the DNS gets its data from that specific file for its zone. Now for such primary master configuration we will run the editor and will confirm that the following three commands are there and not commented on.

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

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

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

To verify this we will open the editor as:

$ sudo vi /etc/bind/named.conf

As a result we will see:

All the three lines are present in the output. Now for example we have a domain “gamer.com” for which we are going to configure so we will edit the file named.conf.local by opening as:

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

Edit the following text in the editor as:

zone “gamer.com” {

type master;



We will copy the contents from the db.local to the db.gamer.com:

$ sudo cp /etc/bind/db.local /etc/bind/db.gamer.com

And at this step, we will open the newly created file gamer.com as:

$ sudo vi /etc/bind/db.gamer.com

Output should be like this:

After making changes we will restart the DNS.

$ sudo systemctl restart bind9

For communication of our created domain “gamer.com” with some IP address we have to do a reverse zone file. For such purpose we will also configure the reverse zone file as:

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

Here we will add the following text:

zone “192.168.18.in-addr.arpa” {

type master;



Where 192.168.18 is the first three octets of my network, here you will replace it with your own. Now we will copy and create the new file with db.10 as:

$ sudo cp /etc/bind/db.127 /etc/bind/db.10

Now we will open this file which we have created and its output should be as shown below:

$ sudo vi /etc/bind/db.10

Output is as follows:

In this last part we will confirm the configurations first by executing all these commands and check whether they generate errors or not:

$ named-checkzone gamer.com /etc/bind/db.gamer.com

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

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

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

Running all the above commands we have received no errors so our DNS has been configured successfully.


DNS is a technique through which we name the domains of different websites alphabetically and numerically so it is easy for servers to understand it. We have learned the configuration of the DNS (domain name system) in the article. We have learned that DNS is used to assign numerical based addresses to the alphabetical domains. We configured the google domain in the command line method and also tested it, also in the terminal method, we did forward and reverse file zone configuration by creating a domain of gamer.com. We hope this article will help you a lot and will resolve all the queries regarding the configuration of the DNS.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.