Categories: UbuntuUbuntu 14.04

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.

forwarders {
       8.8.8.8;
       8.8.4.4;
       };

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.

; BIND data file for local loopback interface
;
$TTL    604800
@ IN SOA ns.krizna.com. root.ns.krizna.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.krizna.com.
@       IN      A       192.168.6.5
@       IN      AAAA    ::1
ns      IN      A       192.168.6.5
www     IN  A 192.168.6.10

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.

; BIND reverse data file for local loopback interface
;
$TTL    604800
@ IN SOA ns.krizna.com. root.ns.krizna.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@      IN      NS      ns.
5      IN      PTR     ns.krizna.com.
10     IN      PTR     www.krizna.com.

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.

// Forward zone
zone "krizna.com" {
        type master;
        file "/etc/bind/db.krizna.com";
};
//reverse zone
zone "6.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.192";
};

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 .

Disqus Comments Loading...
Share
Published by
krizna

Recent Posts

How to install Visual Studio Code on ubuntu 20.04

Visual Studio Code is a popular code editor which is lightweight and cross platform application.…

4 years ago

How to install MySQL workbench on ubuntu 20.04

MySQL workbench is a GUI tool for managing MySQL database system. It is used by…

4 years ago

How to install Android Studio on ubuntu 20.04

Android Studio is a popular development software used especially for developing android applications. It is…

4 years ago

How to install google chrome on ubuntu 20.04

Google chrome is a most popular web browser developed by google. It was developed to…

4 years ago

How to install Zoom on ubuntu 20.04

Zoom is a popular video conferencing software. It is commonly used for conducting online meetings,…

4 years ago

How to install TeamViewer on ubuntu 20.04

TeamViewer is a popular application for desktop sharing and remote control. It is available for…

4 years ago