Configuring bind9 on Ubuntu 10.04

Some of the applications on Ubuntu 10.04 like Gwibber can fail if they don’t get responses quickly enough from a DNS so one solution is to run a local copy of Bind9.

This article covers how to install bind9 on Ubuntu 10.04 to act as a local dns server speeding up dns queries, configuring bind with your local network, adding slaves and how to use bind with remote servers over a vpn.

Defining hosts in your local network

If you have additional hosts within your local network then you should add them to your local dns server.

First you need to create a zone file containing your hosts, so first sudo su – as you need to be root, then create your zone file – I’ll use db.retep here:

peter@kira:~$ sudo su -
peter@kira:~# cd /etc/bind
peter@kira:/etc/bind# vi db.retep

Next the actual zone file. Here’s what mine sort of looks like (it’s really a lot larger):

;
; BIND data file for retep.net
;
$TTL    604800
@       IN      SOA     retep.net. root.retep.net (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      amy.
@       IN      A       192.168.2.3
gate    IN      A       192.168.2.1
hinge   IN      A       192.168.2.2
amy     IN      A       192.168.2.3
tabitha IN      A       192.168.2.4
ezri    IN      A       192.168.2.5
kira    IN      A       192.168.2.6
sabrina IN      A       192.168.2.7

Next you need to create a reverse zone – one that can take an IP address and convert it back to a hostname. Although not strictly necessary it’s useful for some protocols like ssh which do this sort of lookup. I have this in a file called db.192.168.2 and here’s a version which matches the above zone file:

;
; BIND reverse data file for retep.net
;
$TTL    604800
@       IN      SOA     retep.net. root.retep.net. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      amy.retep.net.
1       IN      PTR     gate.retep.net.
2       IN      PTR     hinge.retep.net.
3       IN      PTR     amy.retep.net.
4       IN      PTR     tabitha.retep.net.
5       IN      PTR     ezri.retep.net.
6       IN      PTR     kira.retep.net.
7       IN      PTR     sabrina.retep.net.

The last thing we need to do is tell bind to use those zone files. Edit the named.conf.local file and add the following:

zone "retep.net" {
      type master;
      file "/etc/bind/db.retep";
};

zone "2.168.192.in-addr.arpa" {
      type master;
      file "/etc/bind/db.192.168.2";
};

Finally reload bind:

peter@kira:~# service bind9 reload

On the next page we’ll cover adding a slave server

Author: petermount1

Java nut working in the online gaming industry, prolific Open Source Java developer and member of the XSF Technical Review team

4 thoughts on “Configuring bind9 on Ubuntu 10.04”

  1. Great page. It worked just like you said it would.
    I have set up secondary DNS on Ubuntu 10.04, and the zones have transferred from Go Daddy’s Primary DNS to my secondary.

    It would be great if you could put some info regarding TSIG on Ubuntu 10.04 for secondary DNS.

    Great page! Thank you for sharing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s