How To Install and Configure DNS Server on Ubuntu 16.04 LTS

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

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

sudo apt-get update
sudo apt-get upgrade

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:

apt-get install bind9 bind9utils bind9-doc

Step 3. Configure Bind9.

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

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

options {
directory "/var/cache/bind";
additional-from-auth no;
additional-from-cache no;
version "Bind Server";

// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
8.8.8.8;
8.8.4.4;
};

//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;
allow-recursion { 127.0.0.1; };
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

Step 4. Configure Local File.

Next, we will configure the local file, to specify our DNS zones:

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

//place these lines at the bottom of file

zone "wpcademy.com" {
type master;
file "/etc/bind/zones/wpcademy.com.db";
allow-transfer { 108.200.200.2; };
also-notify { 108.200.200.200.2; };
};

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

mkdir /etc/bind/zones
nano /etc/bind/zones/wpcademy.com.db
$TTL 86400
$ORIGIN wpcademy.net.
@ IN SOA ns1.wpcademy.com. root.wpcademy.com. (
1 ; Serial
86400 ; Refresh
7200 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.wpcademy.com.
@ IN NS ns2.wpcademy.com.
ns1 IN A 108.100.100.1
ns2 IN A 108.100.100.2

;also list other computers
@ IN A 192.30.35.67
www IN A 192.30.35.67

Install and Configure DNS Server on Ubuntu 16.04 LTS

Leave a Reply