Howto: Setup a DNS server with bind9 on Debian/Ubuntu

Valic —  February 1, 2011 — 3 Comments

After I needed a DNS server DNS server, I decided the best idea would probably be to write this howto myself…. So, here it is:

Step 1. Install bind9:

apt-get install bind9

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

vim /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:

#Replace with your own domain name.
zone “” {
type master;
file “/etc/bind/zones/”;

# Replace with your network address in reverse notation – in this example my network address is
zone “” {
type master;
file “/etc/bind/zones/”;

Step 3. Now let’s edit the options file:

vim /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.

# Replace the address below with the address of your provider’s DNS server

forwarders {;

Step 4.Now we will add the zone definition files:

mkdir -p /etc/bind/zones
vim /etc/bind/zones/

The zone definition file is where we will put all the addresses that our DNS server will know.
You can take the following example: IN SOA (
#Do NOT modify the following lines!

#Edit the following line as necessary: IN NS IN MX 10

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

Step 5. Now create the reverse DNS zone file:

vim /etc/bind/zones/

Copy/paste the following text and modify as needed:

@ IN SOA (


Step 6. Restart bind9:

/etc/init.d/bind9 restart

Enjoy this. And don’t forget to comment if something it’s wrong or you want to improve it.


Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

3 responses to Howto: Setup a DNS server with bind9 on Debian/Ubuntu

  1. In Ubuntu you need to copy the files from /etc/bind to /var/lib/bind, or bind won’t be able to update your zone files.

    Also it’s worth emphasising that in the reverse lookup file, the ip addresses should have a period at the end:

    1 IN PTR

    Forgetting this is a very common error (you can have my tee shirt:).


  2. I believe the line “IN NS” should be “@ IN NS”


  3. it works with both ways. with or without @

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.