You are on page 1of 34

24/12/2020 Install and configure DNS server in Ubuntu 16.

04 LTS - OSTechNix

HOME OPEN SOURCE TECHNOLOGY LINUX UNIX FREE EBOOKS AND VIDEOS DONATE CONTACT US
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Home  Linux Distributions  Debian  Install and con gure DNS server in Ubuntu 16.04 LTS

DEBIAN DNS FAQ LINUX LINUX MINT UBUNTU

Install and con gure DNS server in Ubuntu 16.04 LTS


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
Written by Sk August 23, 2016 6046 Views
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 1/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO  25 comments 1    SERVERS


   MOBILE 
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SECURITY 

This comprehensive tutorial describes how to install and con gure DNS server in Ubuntu 16.04 LTS 6
server edition. As you may know already, DNS is the short form of Domain name system, which is us
resolve hostnames into IP addresses and vice versa. For the purpose of this guide, I will be using three sys
one for Primary DNS server, other for secondary DNS, and the third one for DNS client. All systems are ru
with Ubuntu 16.04 operating systems. Here is the IP and host name of each system.

Primary DNS server:

a Free Hosting Control Panel

one-click install LNMP/LAMP developing

aaPanel Open

Operating system : Ubuntu 16.04 LTS 64 bit server

Hostname : pri.ostechnix.lan

IP address : 192.168.1.200/24

Secondary DNS server:

Operating system : Ubuntu 16.04 LTS 64 bit server

Hostname : sec.ostechnix.lan

IP address : 192.168.1.201/24

DNS Client:

Operating system : Ubuntu 16.04 LTS 64 bit server

Hostname : client.ostechnix.lan
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
IP address : 192.168.1.202/24 if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 2/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

LetREAD
us get started.
ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Install and Con gure DNS server in Ubuntu 16.04


I will split this guide as as three parts for the sake of simplicity and easy understanding.

1. Install and con gure Caching-only name server,


2. Install and con gure Primary DNS server or Master DNS server

3. Install and con gure Secondary DNS server or Slave DNS server

Let us do it step by step.

Part 1 : Install and con gure Caching-only name server,

Make sure your Ubuntu server is up-to-date.

sudo apt-get update

sudo apt-get upgrade

sudo apt-get dist-upgrade

Install BIND9

After updating the system, run the following command to install BIND9 packages which are used to setup
server.

sudo apt-get install bind9 bind9utils bind9-doc

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 3/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Install BIND9

Con guring Caching name server

Caching name server saves the DNS query results locally for a particular period of time. It reduces the
server's tra c by saving the queries locally, therefore it improves the performance and e ciency of the
server.

To con gure Caching name server, edit /etc/bind/named.conf.options le:

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

Uncomment the following lines. And then, add your ISP or Google public DNS server IP addresses.

forwarders {
8.8.8.8;
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
}; if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 4/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Save and close the le.

And then restart bind9 service to take e ect the changes.

sudo systemctl restart bind9

We have successfully installed the caching name server.

Testing Caching name server

Now let us check if it is working or not using command:

dig -x 127.0.0.1

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish.
If you see something like below, congratulations! Accept name
Caching Read More is working!
server 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 5/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD
; <<>> DiG 9.10.3-P4-Ubuntu <<>>DATABASE DIRECTORY
-x 127.0.0.1 SERVERS MOBILE  SECURITY 

;; global options: +cmd


;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22769
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.127.in-addr.arpa. IN PTR

;; ANSWER SECTION:
1.0.0.127.in-addr.arpa. 604800 IN PTR localhost.

;; AUTHORITY SECTION:
127.in-addr.arpa. 604800 IN NS localhost.

;; ADDITIONAL SECTION:
localhost. 604800 IN A 127.0.0.1
localhost. 604800 IN AAAA ::1

;; Query time: 0 msec


;; SERVER: 192.168.1.200#53(192.168.1.200)
;; WHEN: Tue Aug 23 15:53:59 IST 2016
;; MSG SIZE rcvd: 132

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 6/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE
a Free Hosting
DIRECTORY SERVERS
Control
MOBILE 
Pa
SECURITY 

one-click install LNMP/LAMP


developing
aaPanel

Part 2 : Install and con gure Primary DNS server

Make sure your Ubuntu server is up-to-date using the following commands:

sudo apt-get update

This
sudo website uses upgrade
apt-get cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 7/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
sudo apt-get dist-upgrade

Install BIND9

Run the following command to install BIND9 packages.

sudo apt-get install bind9 bind9utils bind9-doc

Con guring Primary DNS server

All con guration le be will be available under /etc/bind/ directory.

Let us edit bind9 con guration le

Edit ‘/etc/bind/named.conf’ using any editor of your choice:

sudo nano /etc/bind/named.conf

This le should have the following lines in it. If the lines are not there, just add them.

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 8/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE Imprimez facilement
MOBILE  au
DIRECTORY SERVERS Maroc
SECURITY 

Imprimez plus facilement vos


documents en Ligne. Emballage,
dépliant, bache, vinyle
24hprint.ma - Imprimerie

Save the changes and exit the le.

We need to de ne the forward and reverse zone les.

To do so, edit named.conf.local le:

sudo nano /etc/bind/named.conf.local

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
De ne the forward and reverse lesifas shown
you wish. below.
Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 9/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS
zone "ostechnix.lan" { CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

type master;
file "/etc/bind/for.ostechnix.lan";
allow-transfer { 192.168.1.201; };
also-notify { 192.168.1.201; };
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/rev.ostechnix.lan";
allow-transfer { 192.168.1.201; };
also-notify { 192.168.1.201; };
};

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 10/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Here, for.ostechnix.lan is the forward zone le. rev.ostechnix.lan is the reverse zone
And 192.168.1.202 is the IP address of secondary DNS server. We do this because, the secondary DNS wil
to fetch the queries if primary server is down.

Save and close the le.

Let us now create the zone les which we de ned in the previous step.

First let us create forward zone le as shown below.

sudo nano /etc/bind/for.ostechnix.lan

Add the following lines:

$TTL 86400
@ IN SOA pri.ostechnix.lan. root.ostechnix.lan. (
2011071001 ;Serial
3600 ;Refresh
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
1800 ;Retry
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 11/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

604800
READ ALSO ;Expire
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
86400 ;Minimum TTL
)
@ IN NS pri.ostechnix.lan.
@ IN NS sec.ostechnix.lan.
@ IN A 192.168.1.200
@ IN A 192.168.1.201
@ IN A 192.168.1.202
pri IN A 192.168.1.200
sec IN A 192.168.1.201
client IN A 192.168.1.202

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 12/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Similarly, you can add the other client records as de ned in the above le.

Save and close the le. Next create reverse zone.

sudo nano /etc/bind/rev.ostechnix.lan

Add the following lines:

$TTL 86400
@ IN SOA pri.ostechnix.lan. root.ostechnix.lan. (
2011071002 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS pri.ostechnix.lan.
@ IN NS sec.ostechnix.lan.
@ IN PTR ostechnix.lan.
pri IN A 192.168.1.200
sec IN A 192.168.1.201
client IN A 192.168.1.202
200 IN PTR pri.ostechnix.lan.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 13/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

201 ALSO
READ IN PTR sec.ostechnix.lan.
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
202 IN PTR client.ostechnix.lan.

Save and close the le.

Set the proper permissions and ownership to the bind9 directory.

sudo chmod -R 755 /etc/bind

sudo chown -R bind:bind /etc/bind

Next, we need to verify the DNS con guration les and zone les.

Check the DNS con guration les with commands:

This
sudo website uses cookies to improve
named-checkconf your experience. We'll assume you're ok with this, but you can opt-out
/etc/bind/named.conf
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 14/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
sudo named-checkconf /etc/bind/named.conf.local

If the above commands returns nothing, it means DNS con guration is valid.

Next, check the zone les using commands:

sudo named-checkzone ostechnix.lan /etc/bind/for.ostechnix.lan

Sample output:

zone ostechnix.lan/IN: loaded serial 2011071001


OK

Check the reverse zone le:

sudo named-checkzone ostechnix.lan /etc/bind/rev.ostechnix.lan

Sample output:

zone ostechnix.lan/IN: loaded serial 2011071002


OK

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 15/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

If you got the results as shown above, then everything is good.

Now, it is time to check whether the primary DNS server is working or not.

Edit /etc/network/interfaces le:

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
sudo vi /etc/network/interfaces
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 16/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
Add the DNS server IP address. In our case, the DNS server IP is the same IP address of this machine itself.

dns-nameservers 192.168.1.200

Save and close the le.

Finally, restart Bind9 service.

sudo systemctl restart bind9

Testing primary DNS server

Verify DNS server using dig or nslookup commands.


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 17/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
dig pri.ostechnix.lan

Sample output:

; <<>> DiG 9.10.3-P4-Ubuntu <<>> pri.ostechnix.lan


;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51989
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;pri.ostechnix.lan. IN A

;; ANSWER SECTION:
pri.ostechnix.lan. 86400 IN A 192.168.1.200

;; AUTHORITY SECTION:
ostechnix.lan. 86400 IN NS sec.ostechnix.lan.
ostechnix.lan. 86400 IN NS pri.ostechnix.lan.

;; ADDITIONAL SECTION:
sec.ostechnix.lan. 86400 IN A 192.168.1.201

;; Query time: 0 msec


;; SERVER: 192.168.1.200#53(192.168.1.200)
;; WHEN: Tue Aug 23 16:56:13 IST 2016
;; MSG SIZE rcvd: 110

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 18/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Or, use nslookup command as shown below:

nslookup ostechnix.lan

Sample output:

Server: 192.168.1.200
Address: 192.168.1.200#53

Name: ostechnix.lan
Address: 192.168.1.200
Name: ostechnix.lan
Address: 192.168.1.201
Name: ostechnix.lan
Address: 192.168.1.202

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 19/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

If you got results something like above, then primary DNS server is up and is working perfectly!

Part 2: Install and con gure Secondary DNS server


You need a separate system to setup this server. We need secondary DNS server, because in case o
problem with Primary DNS, then secondary dns server will still resolve quries.

First, Update server using commands:

sudo apt-get update

sudo apt-get upgrade

This
sudo website uses dist-upgrade
apt-get cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 20/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

Install
READBIND9
ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Install required bind9 packages:

sudo apt-get install bind9 bind9utils bind9-doc

Con gure secondary DNS server

Edit bind9 con guration le:

sudo nano /etc/bind/named.conf

Add the following lines if they are not there.

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

Save and close the le.

Next, we need to de ne zone les.

To do so, edit named.conf.local le:

sudo nano /etc/bind/named.conf.local

Add or modify the following lines. Replace IP address and zone les with your own values.

zone "ostechnix.lan" {
type slave;
file "/var/cache/bind/for.ostechnix.lan";
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
masters { 192.168.5.200; };
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 21/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

}; ALSO
READ
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
zone "1.168.192.in-addr.arpa" {
type slave;
file "/var/cache/bind/rev.ostechnix.lan";
masters { 192.168.5.200; };
};

Here, 192.168.1.200 is the IP address of the primary DNS server.

Please note that the path of zone les must be /var/cache/bind/ directory. It is because AppArmor only
write access inside it by default.

Next set the proper permission and ownership to the bind directory.

This
sudo website
chmoduses
-Rcookies to improve your experience. We'll assume you're ok with this, but you can opt-out
755 /etc/bind
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 22/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS
sudo chown -R bind:bindCLOUD DATABASE
/etc/bind DIRECTORY SERVERS MOBILE  SECURITY 

Then, edit network con guration le and add the primary and secondary DNS server's IP address.

sudo nano /etc/network/interfaces

[...]
dns-nameservers 192.168.1.200
dns-nameservers 192.168.1.201

Save and close the le.


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 23/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

Finally,
READ reboot
ALSOyour system to take e ect the all changes.
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Testing Secondary DNS server

As I mentioned already, we use "dig" or "nslookup" commands to test DNS server.

Let us verify the secondary DNS server with command:

dig sec.ostechnix.lan

Sample Output:

; <<>> DiG 9.10.3-P4-Ubuntu <<>> sec.ostechnix.lan


;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49308
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;sec.ostechnix.lan. IN A

;; ANSWER SECTION:
sec.ostechnix.lan. 86400 IN A 192.168.1.201

;; AUTHORITY SECTION:
ostechnix.lan. 86400 IN NS sec.ostechnix.lan.
ostechnix.lan. 86400 IN NS pri.ostechnix.lan.

;; ADDITIONAL SECTION:
pri.ostechnix.lan. 86400 IN A 192.168.1.200

;; Query time: 2 msec


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
;; SERVER: 192.168.1.200#53(192.168.1.200)
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 24/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

;; WHEN:
READ Tue Aug 23 18:19:47 IST 2016
ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
;; MSG SIZE rcvd: 110

Similarly, you can verify primary DNS server with command:

dig pri.ostechnix.lan

Or, just use nslookup command as shown below.

nslookup ostechnix.lan

Note: Please note that the zone les will be transferred only when the Serial Number on the Primary
server is higher than the Secondary DNS server's serial number.

Con guring DNS client


EditThis website
network usesguration
con cookies toleimprove your experience.
in the client system: We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 25/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
sudo nano /etc/network/interfaces

Add the nameserver IP addresses.

[...]
nameserver 192.168.1.200
nameserver 192.168.1.201

Save and close the le. Then, reboot your system to take e ect the changes.

Test the DNS servers using any one of the following commands:

dig pri.ostechnix.lan

dig sec.ostechnix.lan

dig client.ostechnix.lan

nslookup ostechnix.local

At this stage, you will have working primary and secondary DNS servers.

Also read - How to Setup DNS Server in CentOS 6


Don't forget to download the following free EBOOK that explains how to install and con gure various serve
applications on your Ubuntu system.
Download - Free eGuide: "Ubuntu Documentation: Ubuntu Server Guide 2014"
That's all for now. If you nd this guide useful, please share it on your social networks and support OSTech
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out

Cheers! if you wish. Accept Read More 


Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 26/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD
Thanks for stopping
DATABASE
by!
DIRECTORY SERVERS MOBILE  SECURITY 

How can I bene t from this blog:

Subscribe to our Email Newsletter : Sign Up Now

Download free E-Books and Videos : OSTechNix on TradePub

Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds

Have a Good day!!

BIND9 DNS DNS SERVER UBUNTU 16.04 LTS

 25 comments 1       

SK

I am Senthil Kumar, more commonly known as SK to my friends, from India. I love to read, write
explore topics on Linux, Unix and all other technology related stu .

   

Previous post Nex


YouTube hacks – Record your Computer using How to Install Oracle VirtualBox in Fre
YouTube

YOU MAY ALSO LIKE

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 27/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

Keep CentOS 6 Servers Safe From How To Upgrade Alpine Linux To Vagrant Tutorial – Getting Sta
READ ALSO
HOME A New...
BACKUP TOOLS CLOUD Latest Version
DATABASE DIRECTORY SERVERS MOBILEWith
 Vagrant
SECURITY 

25 COMMENTS

VAN PHAM

 December 9, 2016 - 10:50 am

Thanks for this guide but i found the problems when i do following your.
When i check : dig -x 127.0.0.1, or : dig pri.ostechnix.lan
The server i see if di rence
SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Dec 09 17:40:03 ICT 2016
;; MSG SIZE rcvd: 132
That’s all wrong the IP ADDRESS. (I’m a newbie using ubuntu)
Any help ! Tks.

SK

 December 9, 2016 - 2:49 pm

If you have followed the exact steps, you shouldn’t have got this message. Did you add the D
server IP in your /etc/network/interfaces le? If not, add it and try again. It should work. I hav
checked this guide multiple times on my local network. It worked every time as I explained.

EDIVALDO SANTOS

 January 11, 2017 - 11:10 pm

I tried it once it worked properly..thanks But i have a question.. Where should i add the secondary DN
zone. I’m trying to use primary,secondary, and client in the same server. I couldn’t gure out if your
instructions for secondary DNS zone were to add it on sudo nano /etc/bind/named.conf.local where
primary is installed or if its has to be installed in another machine? please help me with that, and if yo
add some tips MX records con guration. thanks.

This website uses cookies


SK to improve your experience. We'll assume you're ok with this, but you can opt-out
if -you
 January 12, 2017 6:14wish.
am Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 28/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO How can you use the same server for primary and secondary DNS? As far as I know it’s
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
impossible.

EDIVALDO SANTOS

 January 12, 2017 - 9:34 am

alyt! Thanks.

NISAR

 April 18, 2017 - 5:49 pm

it have to be another machine

OSCAR

 August 6, 2017 - 12:22 pm

Hi, a question this steps is only for local network or this found for a real domain…??
Thanks for you reply and very nice tutorial.

SK

 August 6, 2017 - 2:54 pm

Due to the limited resources, I didn’t check it for real domain. But the same steps should wor
wither local or wan.

OSCAR

 August 7, 2017 - 9:23 am

Ok…
Thank you very much.

JOHN CUNNINGHAM

 August 8, 2017 - 12:36 am

This website uses cookies


everything workedto improve your
ne up until experience.
i did We'll guess
a NSLOOKUP, assume you're
you okonce
forgot with small
this, but you can opt-out
step:
if you wish.
the step to edit /etc/resolv.conf Accept
le, and add ReadIPMore
DNS server address. 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 29/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

sudo nano /etc/resolv.conf


READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
nameserver 192.168.1.200
please add to your tutorial, thanks for the tutorial, everything else worked ne.

ARCHIE MURRELL

 September 10, 2017 - 9:29 pm

Great tutorial SK
I got primary DNS working on a server because of the this very informative tutorial.

SK

 September 11, 2017 - 12:49 pm

Glad it helped you. Keep visiting!

ADITYA WIBOWO

 May 21, 2018 - 10:04 am

Hi, thank you for the tutorial


I have a question, i want to build a mail server just for my campus homework, can i just build 1 DNS to
operate the mail server?
and if i need more than 1 DNS, is it mean i need another OS to make the 2nd DNS?

SK

 May 21, 2018 - 12:09 pm

Yes. We need two systems to setup primary and secondary dns servers.

BRIAN

 June 22, 2018 - 5:15 pm

Here, for.ostechnix.lan is the forward zone le. rev.ostechnix.lan is the reverse zone les. And
192.168.1.202 is the IP address of secondary DNS server. We do this because, the secondary DNS will
to fetch the queries if primary server is down. Shouldn’t this line say 192.168.1.201 because 202 is not
secondary dns according to opening statement.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
Secondary DNS server:
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 30/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

Operating system : Ubuntu 16.04 LTS 64 bit server


READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
Hostname : sec.ostechnix.lan
IP address : 192.168.1.201/24

THIAGO VINCENZI CONRADO

 August 31, 2018 - 7:22 pm

agree

BENNIO

 July 28, 2018 - 3:26 pm

Thank you for the tuto.


I have a problem, client can ping server address but can’t ping with domain name, when I use dig, I go
message : (connection timed out: no server could be reach )

SURESH

 August 22, 2018 - 10:44 pm

i installed with your insruction working well in local network i want to use as puplic dns server i have
ns1.mydomain.com with a record point with public ip how to do that kindly help me we are internet se
provider

AKHIL

 October 22, 2018 - 8:20 pm

I’ve followed the step by step of the document but changed the names and addresses wherever neces
After dig pri.*****.lan , my output is not showing the answer. It says answer : 0 . But in the output of y
the answer :1

BHAGWANT SINGH

 March 2, 2019 - 1:26 am

will you please evaluate that how we can create a forward lookup zone and reverse lookup zone i tried
thrice but nothing is working, so i need your help..
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 31/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

ROGER
READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
 May 10, 2019 - 10:43 pm

To con gure a DNS server is it necessary for the domain to be registered?

SK

 May 11, 2019 - 11:49 am

Yes, you should register the domain. If it is local DNS server, it is not required.

BHARGAVI

 June 22, 2019 - 7:09 pm

Hi
When I run “dig pri.ostechnix.lan” in the output part I am not getting details related to secondary dom
name server. Is there anything need to be con gured.

LOUIS

 November 14, 2019 - 7:48 pm

Hello when i type nslookup “localhost” the server says “server can’t nd “localhost”: SERVFAIL

EDNO

 December 13, 2019 - 1:36 am

Great guide. It helped me a lot!


I didn’t nd where to rate, but you got ve of ve stars.
Thanks!!!

LEAVE A COMMENT

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 32/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
Your Comment
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 

Name* Email* Website

Save my name, email, and website in this browser for the next time I comment.

* By using this form you agree with the storage and handling of your data by this website.

SUBMIT

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ABOUT OSTECHNIX POPULAR POSTS

1
Youtube-dl Tutorial With
Examples For Beginners
June 26, 2019

OSTechNix (Open Source, Technology, Nix*) regularly


2
publishes the latest news, how-to articles, tutorials and How To Find The Size Of A
Directory In Linux
tips & tricks about free and opensource software and
December 26, 2017
technology.

       3
How To Fix Broken Ubuntu O
Without Reinstalling It
April 25, 2020

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 33/34
24/12/2020 Install and configure DNS server in Ubuntu 16.04 LTS - OSTechNix

READ ALSO
HOME BACKUP TOOLS CLOUD DATABASE DIRECTORY SERVERS MOBILE  SECURITY 
About Contact Us Privacy Policy Sitemap Term

OSTechNix © 2020. All Rights Reserved. Designed and Developed by Anblik. This site

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out
if you wish. Accept Read More 
Con dentialité - Conditions

https://ostechnix.com/install-and-configure-dns-server-ubuntu-16-04-lts/ 34/34

You might also like