How to Setup DHCP Server with Dynamic DNS using Bind9 in Debian Etch and Ubuntu 8.04

This tutorial is a continuation of my previous post here which covers the installation of bind9 on a Debian Etch and Ubuntu 8.04 system. This new tutorial will cover the Dynamic DNS features of bind9.

I assume that you have a running DNS server and configured based on this tutorial.

First we will change the owner of /var/cache/bind to user:bind and group:bind.

chown bind. /var/cache/bind

We will update the file /etc/bind/named.conf.local and make some few changes. The changes that have been added to the file are highlighted in bold.

// Do any local configuration here

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

include "/etc/bind/rndc.key";

controls {
        inet allow { localhost; } keys { "rndc-key"; };

zone "debian.lan" {
        type master;
        file "db.debian.lan";
        allow-update { key "rndc-key"; };

zone "" {
        type master;
        file "db.192.168.100";
        allow-update { key "rndc-key"; };

Install and configure dhcp3-server

apt-get install dhcp3-server
vi /etc/default/dhcp3-server

Configure which interface the dhcpd server should listen to. I this case, I assume that our LAN interface is "eth1".

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts

# This is a POSIX shell fragment

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".

Then we will configure the dhcp configuration file, create a backup of the file /etc/dhcp3/dhcpd.conf and edit it.

cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.bak
vi /etc/dhcp3/dhcpd.conf

Make sure the configuration file should be exactly the same like this:

ddns-update-style       interim;
ignore                  client-updates;

include "/etc/bind/rndc.key";

zone debian.lan. {
        key     "rndc-key";

subnet netmask {
        range                 ;
        option domain-name-servers;
        option domain-name              "debian.lan";
        option routers        ;
        default-lease-time              600;
        max-lease-time                  7200;

        zone main.debian.lan. {
                key "rndc-key";

        zone {
                key "rndc-key";

Restart the DNS server and the DHCP server.

/etc/init.d/bind9 restart
/etc/init.d/dhcp3-server restart

Your DDNS server should be ok. Now, if your client in your LAN is Ubuntu, you need to edit the file /etc/dhcp3/dhclient.conf.

vi /etc/dhcp3/dhclient.conf

Add the following information

send host-name "pc-name";

and run this command to renew your ip address and domain name.

dhclient eth0

If you are using Fedora, CentOS or RHEL, edit the file

vi /etc/sysconfig/network-scripts/ifcfg-eth0

append the hostname


and restart the network service.
Test your client domain name using dig or nslookup command:

nslookup ubuntu01

the command will return the following message:


Name:	ubuntu01.debian.lan

Check the reverse dns


the command will return the following message:

Address:	name = ubuntu01.debian.lan.

Have fun!