How to setup DNS server with bind on Ubuntu

Step 1: Install Ubuntu or use your WORKING installation.

Step 2: Install bind 9:

sudo apt-get install bind9

Step 3: Configure the main Bind files.

Usually, if you install Bind from the source code, you will have to edit the file named.conf. However, Ubuntu provides you with a pre-configured Bind, so we will edit another file:

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

This is where we will insert our zones. By the way, a zone is a domain name that is referenced in the DNS server.
Insert this in 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/";

Ok, now, let's edit the options file:

sudo vi /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 he cannot process.

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

Now, let's add the zone definition files (replace with your domain name:

sudo mkdir /etc/bind/zones
sudo vi /etc/bind/zones/

The zone definition file is where we will put all the addresses / machine names that our DNS server will know. You can take the following example:      IN      SOA (
 )      IN      NS          IN      MX     10

www              IN      A
mta              IN      A
ns1              IN      A

Now, let's create the reverse DNS zone file:

sudo vi /etc/bind/zones/

Copy and paste the following text, modify as needed:

@ IN SOA (

                     IN    NS
1                    IN    PTR

Ok, now you just need to restart bind:

sudo /etc/init.d/bind9 restart

We can now test the new DNS server.

Step 4: Modify the file resolv.conf with the following settings:

sudo vi /etc/resolv.conf

Enter the following:


Now, test your DNS:


Source: Ubuntu Community

  1. Sridhar Sarnobat
    2014-09-03 06:46:31
    Excellent Tutorial, thanks. I found others very intimidating. I was surprised I got mine to work :) Just one comment - you could add some comments to indicate what is. It took me a while to indicate that it's the machine where bind is installed.

Got a comment?

captcha =


  1. System (20)
    1. FreeBSD (5)
    2. Linux (9)
  2. Email (2)
  3. DNS (2)
  4. Databases (1)
  5. WebServer (27)
Copyright © 2024 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.