Skip to main content

How to configure DNS server in ubuntu 14.04

DNS server is used to resolve domain name into IP address. There are three common DNS server configurations can be done using BIND, caching nameserver, primary master and secondary master more info.
Here in this post we can see about how to install and configure DNS server in ubuntu 14.04.

DNS server installation

Step 1 » Update the repositories.
sudo apt-get update
Step 2 » Install bind9 using the below command.
sudo apt-get install bind9Now installation is over, please proceed with configuration.

Caching nameserver

Caching nameserver will remember all the DNS queries made and serves locally when the domain is queried second time. Default configuration will act as a caching nameserver, you just need is to add public DNS IPs in the configuration file.

Step 3 » Open /etc/bind/named.conf.options file and find forwarders column , uncomment and edit like the following.

Here and are google public DNS servers .

Step 4 » Now start/restart the service.
sudo service bind9 restart
Step 5 » Now test using dig command . open /etc/resolv.conf and edit nameserver ip to or your serverIP.
nameserver type the below command to see results.
krizna@ns:~$ dig
;; Query time: 83 msec
It took 83 msec for the first time . Now try the same command again.
krizna@ns:~$ dig
;; Query time: 5 msec
Now reduced to 5 msec . This time it serves from local.

Primary master

Primary master configuration is just like managing DNS records for particular domain locally ( Eg: ).
Scenario details:
Domain name :
Server ip :
Server hostname :
Webserver ip : ( .
We need to create 2 zone files , Forward zone and reverse zone.

Forward zone file

Step 6 » Create forward zone file by copying db.local conf file.
sudo cp /etc/bind/db.local /etc/bind/
Step 7 » Now open /etc/bind/ and edit like below.

Reverse zone file

Step 7 » Create reverse zone file db.192 by copying db.172 conf file.
sudo cp /etc/bind/db.127 /etc/bind/db.192
Step 8 » Now open /etc/bind/db.192 file and edit like below.

Step 9 » Now open /etc/bind/named.conf.local configuration file and add the below lines to include forward and reverse zone files . 6.168.192 in reverse column is just first three octets of your network.

Step 10 » Now restart the service.
sudo service bind9 restart
Step 11 » Now test using nslookup or dig commands.
krizna@ns:~$ nslookup
Now test reverse lookup
krizna@ns:~$ nslookup
Address: name =
That’s it , Your DNS server is ready .