Setup DNS Server on Ubuntu Server

Enter administrative/root mode:

sudo su

Install DNS Server (BIND):

apt-get install bind9

Configure the main BIND files:

nano /etc/bind/named.conf.local

This is where we will insert our zones. A zone is a domain name that is referenced in the DNS Server. Insert this into the named.conf.local file:

# This is the zone definition. replace with your domain name
zone "" {
        type master;
        file "/etc/bind/zones/";

# This is the zone definition for reverse DNS. replace 0.168.192 with your network address in reverse notation - e.g my network address is 192.168.0
zone "" {
     type master;
     file "/etc/bind/zones/";


Now let's edit the options file:

nano /etc/bind/named.conf.options

We need to modify the forwarder. This is the DNS Server to which your own DNS will forward the requests it cannot process:

forwarders {
      # Replace the address below with the address of your provider's DNS server;


Now we add the zone definition files (replace with your domain name):

mkdir /etc/bind/zones
cd zones

The zone definition file is where we put all the addresses / machine names that our DNS server will use. You can take the following example:

// replace with your domain name. do not forget the . after the domain name!
// Also, replace ns1 with the name of your DNS server      IN      SOA (
// Do not modify the following lines!

// Replace the following line as necessary:
// ns1 = DNS Server name
// mta = mail server name
// = domain name      IN      NS          IN      MX     10

// Replace the IP address with the right IP addresses.
www              IN      A
mta              IN      A
ns1              IN      A