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 8.8.8.8 and 8.8.4.4 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 127.0.0.1 or your serverIP.
nameserver 127.0.0.1Now type the below command to see results.
krizna@ns:~$ dig www.krizna.com
................
;; Query time: 83 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
.................
It took 83 msec for the first time . Now try the same command again.
krizna@ns:~$ dig www.krizna.com
................
;; Query time: 5 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
.................
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: krizna.com ).
Scenario details:
Domain name : krizna.com
Server ip : 192.168.6.5
Server hostname : ns.krizna.com
Webserver ip : 192.168.6.10 ( www.krizna.com) .
We need to create 2 zone files , Forward zone and reverse zone.

Forward zone file

Step 6 » Create forward zone file db.krizna.com by copying db.local conf file.
sudo cp /etc/bind/db.local /etc/bind/db.krizna.com
Step 7 » Now open /etc/bind/db.krizna.com 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 www.krizna.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.krizna.com
Address: 192.168.6.10
Now test reverse lookup
krizna@ns:~$ nslookup 172.27.6.10
Server: 127.0.0.1
Address: 127.0.0.1#53
10.6.27.172.in-addr.arpa name = www.krizna.com.
That’s it , Your DNS server is ready .

  • djegsi

    Good tutorial , can you help me how l can add these DNS to cpanel where l am hosting a domain name ?

  • djegsi

    Good tutorial , can you help me how l can add these DNS to cpanel where l am hosting a domain name ?

  • ,,,,,,,

    dude can u tel me about how to make it external … i got angry about f**ing internal tutorials …. where is the point … come one do someting useful

  • ,,,,,,,

    dude can u tel me about how to make it external … i got angry about f**ing internal tutorials …. where is the point … come one do someting useful

  • Calvin Mitchell

    I followed the instructions…but when i did the nslookup for my local domain i got a totally different ip address; while it should’ve read ‘192.168.1.6’ i got ‘192.105.244.228’.

  • Calvin Mitchell

    I followed the instructions…but when i did the nslookup for my local domain i got a totally different ip address; while it should’ve read ‘192.168.1.6’ i got ‘192.105.244.228’.

  • Sprite Sriprom

    i can’t do it in last step.

  • Asep Dadan

    request high availability drbd pacemaker corosync in debian