configure BIND Server with Ubuntu 16.04


All of  Linux users are already families with BIND service, already a lots of articles has been published with recent Ubuntu Linux versions , you can go through all of them, BIND is a dns service which assign a unique name to your IP Address which is termed a “domain name”, so that it becomes easy to resolve some ip address over the internet or even on a local area network. A network con possess only one specific domain name. When some IP Domain Name is resolved to its IP Address then it is know  as forward zone and when a IP address is back to its name it is known as reverse zone. Only to purpose of dns is to simply network queries, imagine a world where all websites are knows with their ip addresses only, there will be a big chaos as human memory can no memories so many IP Address digits, but it is always easy to remember some name that is why we assign name to IP Address on any network.

How to install DNS  on Ubuntu  Server 16.04 ?



Our domain name :

IP Address:

forward zone configuration file name: /etc/bind/

reverse zone configuration file name: /etc/bind/db.192

First of all download a fresh piece of Ubuntu 16.04, make a bootable device and install to server/desktop of your choice.

update system

# apt-get update

Check your IP addresses:

# ip a



Installed required packages

# apt-get install bind9 bind9utils

Have a look in installed directory

# cd /etc/bind && ls

Directory will look something like

dns(003)Let us create caching only name server first

Open /etc/bind/named.conf.options, find forwards and put  dns address of your ISP

Sample output

forwarders {;

Now let us resolve and see what difference this caching only server will make, note down time query time in first attempt.

# dig

Output will be something like

dns(001)  Let us repeat same dig command again and see the difference in output

dns Query time is zero, you can see that how quick caching only bind service can resolve dns server.

Let us configure BIND master server now, first of all make some settings in /etc/resolv.conf. Open file and type:

# vim /etc/resolv.conf



Replace your domain name and your IP address mentioned in demo.

Change directory to /etc/bind

# cd /etc/bind

Open named.conf.local

# vim named.conf.local

Our con configuration file is something like below

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "" {
 type master;
 file "/etc/bind/";
zone "" {
 type master;
 file "/etc/bind/db.192";

Now, our zone name is “” which will be our dns name, server is master server, so we have defined server type as master. Configuration file will be Similarly  for reverse lookup we have do define for our ip address, type first three digits of yor ip address in reverse order before File for reverse zone will be db.192. Make sure your have provided appropriate location for your zone configuration files.

Configure Forward zone

copy db.local sample file to

# cp db.local db.rajneesh.conf

Open and edit

# vim /etc/bind/

Configure file

; BIND data file for local loopback interface
$TTL 604800
@ IN SOA (
 2 ; Serial
 604800 ; Refresh
 86400 ; Retry
 2419200 ; Expire
 604800 ) ; Negative Cache TTL
@ IN A
www IN A is domain name which we are willing to resolve, make sure that you have put dot (.) after every domain name definition. is email id for this domain. NS will be name server for this domain. Put A record for your host e.g. www.

Save and quit, restart bind service.

# /etc/init.d/bind9 restart

Let us check whether this are working proper or not.

# /etc/init.d/bind9 status

dns(002) Thing looks good at this stage.

Resolve dns name.

# dig @

Sample output

; <<>> DiG 9.10.3-P2-Ubuntu <<>> @
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37282
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

; EDNS: version: 0, flags:; udp: 4096
; IN A




;; Query time: 0 msec
;; WHEN: Mon Mar 14 20:34:43 IST 2016
;; MSG SIZE rcvd: 91

We have a green signal in ANSWER section. so let us move to configure reverse zone.

copy db.127 sample file to db.192 and edit

# cp db.127 db.192

Edit file

; BIND reverse data file for local loopback interface
$TTL 604800
@ IN SOA (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
250 IN PTR


File is almost a replica of forward zone file, except PTR or pointer record, which we have to mention in reverse zone file. 250 is the last digit of our ip address. Save and exit.

Restart server

# /etc/init.d/bind9 restart

nslookup IP address of your domain server.


Sampe output

Address: name =

Things are working good. This is all for now, Have fun!