ComTech: IT Support Stirling

How to set up a DNS server on Ubuntu Server 12.04 LTS

ComTech: IT Support Stirling

Today I will show you how to set up a DNS server on Ubuntu Server 12.04 LTS.

The first thing to do is to install the software we need, in this case we need the bind9 package. Open up a terminal and type:

sudo apt-get install bind9

Once installed it is time for some configuring. The first file we need to configure is named.conf.local. So in the terminal type:

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

I have used nano to open up the file but use whichever text editor you are happy with. Insert the following code into the 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/”;

Replace with the name of your DNS domain (this is not the same as an active directory domain but rather a name for your DNS zone).

Next up is the options file. In the terminal type:

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

Within this file we need to modify the forwarder with the address of your ISP’s DNS servers. So modify the file adding the following:

forwarders {;;

Replace the addresses above with the addresses of your ISP’s DNS servers.

Now we need to add the zones file:

sudo mkdir /etc/bind/zones

And then configure it:

sudo nano /etc/bind/zones/ (replace with your DNS domain).

Add the following code to the file:

// 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
chris-server IN A

In the above code replace the following: with your DNS domain name, with your static DNS server address, with your computers hostname.dns-domain,

mta is your mail server (if you have one). If you do modify the IP address to show this.

Next we have to create the reverse DNS zone file:

sudo nano /etc/bind/zones/

Add the following code:

//replace with your domain name, ns1 with your DNS server name.
// The number before IN PTR is the machine address of the DNS server
@ IN SOA (


All that is left to do is restart bind:

sudo service bind9 restart

Don’t forget to test the new configuration:



If you are unable to restart the bind9 service run the command named -g 53 which will give you a list of any configuration errors.

About the Author


Hi I’m Chris Wakefield the owner of ComTech IT Support. I provide Windows, Mac and Linux based IT Support to small businesses in Stirling, Alloa and Falkirk.

Follow @Comtech247 on Twitter



6 thoughts on “How to set up a DNS server on Ubuntu Server 12.04 LTS

  1. When I restart bind I get this error:

    * Stopping domain name service… bind9 rndc: connect failed: connection refused
    [ OK ]
    * Starting domain name service… bind9 [fail]

  2. It works for me thanx hadsjkfgdask jlhgludsakhfg ;l
    sdfk jasl flkjsd
    sdh sjdgbf

    “ = ” in my Ubuntu system nano check it and correct it..

    Your Sincerely,
    JumbuLingam Varun Gupta

  3. worked for me.
    Only change I had to do was to add an open parentheses after the hostname in the .db file (like is present in it’s the reverse lookup partner)
    Thanks for the great guide!

  4. It didnt work for me either, the domain still wont go to the /var/www folder where my php files are, i did install apache2, php5 and mysql5 and configured then correctly like i been doing for years but this to setup BIND didnt work, of course i never had to set up my own bind untill now.

  5. Hi
    we are planning to host a website in our office i installed ubuntu 12 server and host the site also it will get through ip http:\\ how configure to a domain name
    my hostname is server , we register one domain my ip details

    please help me to configure dns

Leave a comment

Your email address will not be published.


Get every new post delivered to your Inbox

Join other followers

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera
WP Like Button Plugin by Free WordPress Templates