How To Install and Configure DNS Server on Ubuntu 16.04 LTS

In this tutorial we will show you how to install and configuration DNS server on Ubuntu 16.04 LTS. For those of you who didn’t know, BIND is a widely used DNS Server. Ideally, DNS server consist of 2 machines that work together simultaneously, one act as master and the other one act as slave. If your domain registrar doesn’t provide you a free DNS server, or if you want to create a custom DNS record, then you might need to host your own DNS server.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation and configure DNS server on ubuntu on a Ubuntu 16.04 (Xenial Xerus) server.

Install and Configure DNS Server on Ubuntu 16.04 LTS

Host

Role

Private FQDN

Private IP Address

ns1

Primary DNS Server

108.100.100.1

ns2

Secondary DNS Server

108.100.100.2

host

Generic Host

idroot.net

192.30.35.67

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

1

2

sudoapt-getupdate

sudoapt-getupgrade

Step 2. Installing DNS Server Bind9.

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

1

apt-getinstallbind9bind9utilsbind9-doc

Step 3. Configure Bind9.

It is time to show you a basic configuration how to setup your domain to resolve to your server:

Because in the above config we put zone file in “/etc/bind/zones/idroot.net.db”, then we need to create the folder and file:

1

2

mkdir /etc/bind/zones

nano /etc/bind/zones/idroot.net.db

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

$TTL86400

$ORIGINidroot.net.

@INSOA ns1.idroot.net.root.idroot.net.(

1;Serial

86400;Refresh

7200;Retry

2419200;Expire

604800);NegativeCacheTTL

;

@INNS ns1.idroot.net.

@INNS ns2.idroot.net.

ns1 INA108.100.100.1

ns2 INA108.100.100.2

;alsolistothercomputers

@INA192.30.35.67

www INA192.30.35.67

And then restart bind9 service to take effect the changes:

1

systemctlrestartbind9

Step 5. Configure Secondary DNS Server.

Configure slave bind options:

1

2

3

4

5

6

7

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

zone"idroot.net"{

typeslave;

file"/var/cache/bind/idroot.net.db";

masters{108.100.100.1;};

};

Restart bind9 service to take effect the changes:

1

systemctlrestartbind9

This DNS server will not work until you change your domain’s nameserver. It can be done from your domain’s registrar website. In this scenario, we change nameserver to:

ns1.idroot.net
ns2.idroot.net

Step 6. Testing BIND.

Finally, this test could be done either on the DNS server itself or from another server, or from your own PC. In this case, we will do the test from another server running Ubuntu OS.

Install dnsutils:

1

apt-get install dnsutils

Do the dig dns test:

1

dig idroot.net

Do the nslookup dns test:

1

nslookup idroot.net

Congratulation’s! You have successfully installed DNS server. Thanks for using this tutorial for installing DNS server on Ubuntu 16.04 LTS (Xenial Xerus) system. For additional help or useful information, we recommend you to check the official bind9 web site.

VPS Manage Service Offer

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!