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.

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 which will handle the requests locally. This will not only solve some of the problems but would also speed up dns lookups in general.

A simple installation

First you need to install bind:

peter@kira:~$ sudo apt-get update
peter@kira:~$ sudo apt-get install bind9 dnsutils

Configure local networking

Next you need to configure networking to always use your local bind. Now this depends on if you are using static IP’s or DHCP.

For static IP’s simply replace the dns server addresses with that of your server, either 127.0.0.1 or it’s own IP address on your network.

For DHCP, you need to tell it to ignore the dns settings. To do this:

  1. right click the network icon in the tool bar and select Edit Connections
  2. select the interface you want to use the dns server like Auto eth0 and press Edit
  3. Select the IPv4 Settings tab and change the method from Automatic (DHCP) to Automatic (DHCP) addresses only.
  4. Apply everything and you should be set.

Common problems to look out for

The following are common problems you should be aware of before you setup bind9.

IPv4 or IPv6

Ubuntu comes with both IPv4 and IPv6 enabled, however if you are not using IPv6 – or quite probably your ISP is still not supporting it either you may notice bind is a bit slow. This is because it’s trying to do lookups using IPv6 first, timing out so it then uses IPv4 which works.

To fix this you need to turn off IPv6 within bind.

peter@kira:~$ sudo vi /etc/default/bind9

Find the line starting with OPTIONS= and add -4 to it. Here’s what mine looks like.

# run resolvconf?
RESOLVCONF=yes

# startup options for the server
OPTIONS="-4 -u bind"

Once you have done that, when you next start/restart bind9 it will use IPv4 only.

Installing bind9 with dnsmasq already installed

If you already have dnsmasq installed you must either uninstall it first or, if you want to keep it as your DHCP server, disable it’s DNS server first otherwise the installation will fail as both cannot use the same port.

Now with dnsmasq you can’t actually do this but you can trick it by getting it to run on a different port. Simply edit /etc/dnsmasq.conf and add the following line near the top of the file:

port=54

Once you have done that then restart dnsmasq then you’ll be able to install bind.

Next we’ll cover how to create zone files defining your local network

Upgrading Ubuntu to 10.04 quickly

Ubuntu provides a fairly fool proof way to upgrade from one version to the next but it can take literally hours – when I upgraded my netbook from 9.10 it took just over 4 hours.

The reason for this is that ubuntu’s update-manager downloads everything. What’s worse is if you want to upgrade from a version earlier than 9.10 you must upgrade one release at a time.

Now I’ve got one machine that’s running 8.10, so I’ve got to upgrade to 9.04 first, then 9.10 before I can upgrade to 10.04. If it’s going to take 4 hours a piece then that’s 12 hours at least.

So how can you speed things up if you have either a slow connection or if you have to do multiple upgrades?

Well there’s two ways, the first is to upgrade from scratch – however that’s not viable if you are upgrading a configured machine that gets heavy usage.

The other is to use the alternative iso’s and upgrade from there.

So for that machine running 8.10, I need to download the 9.04, 9.10 and 10.04 alternative iso’s, in this case the for the i386 platform.

Here’s some links to those iso’s:

Version alternate iso
Homepage i386 amd64
9.04 http://releases.ubuntu.com/releases/9.04/ ubuntu-9.04-alternate-i386.iso ubuntu-9.04-alternate-amd64.iso
9.10 http://releases.ubuntu.com/releases/9.10/ ubuntu-9.10-alternate-i386.iso ubuntu-9.10-alternate-amd64.iso
10.04 http://releases.ubuntu.com/releases/10.04/ ubuntu-10.04-alternate-i386.iso ubuntu-10.04-alternate-amd64.iso

Now for the upgrade process. Either burn each iso to disk, or mount it locally and run the upgrade.

peter@kodos:~$ sudo mount -o loop ubuntu-9.04-alternate-i386.iso /media/cdrom0

Ubuntu should show the upgrade dialog, however if it doesn’t – or you are doing this over an ssh connection then you can start it manually – just remember to use -Y with the ssh command 😉

peter@kang:~$ ssh -Y kodos
peter@kodos:~$ sudo mount -o loop ubuntu-9.04-alternate-i386.iso /media/cdrom0
peter@kodos:~$ gksu "sh /cdrom/cdromupgrade"

You must do this for each step and you can’t skip any of them.

Tip: It will prompt you to check for updates during the procedure. Unless you are upgrading to the latest version, or the intermediate steps (9.04, 9.10 etc) you can safely say no here. This will actually save you a lot of time downloading updates only to wipe them out with the next upgrade.

I found that going from 8.10 to 9.04 took about an hour, but 9.04 to 9.10 just half an hour – a big saving.

Update 2010-05-05: If you are remotely updating a server (i.e. does not have desktop installed) then you can’t use gksu as above. Instead use:

peter@kang:~$ ssh kodos
peter@kodos:~$ sudo mount -o loop ubuntu-9.04-alternate-i386.iso /media/cdrom0
peter@kodos:~$ sudo /cdrom/cdromupgrade