Main Menu (suckerfish)

Debian and Ubuntu DDNS with Bind9 and DHCP

This tutorial is a continuation of my previous post How to setup a LAN DNS server using Bind9 under Debian and Ubuntu Linux which covers the installation of bind9 on a Debian/Ubuntu 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 127.0.0.1 allow { localhost; } keys { "rndc-key"; };
};

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

zone "100.168.192.in-addr.arpa" {
        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".
INTERFACES="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. {
        primary 127.0.0.1;
        key     "rndc-key";
}

authoritative;
subnet 192.168.100.0 netmask 255.255.255.0 {
        range                           192.168.100.2 192.168.100.3;
        option domain-name-servers      192.168.100.1;
        option domain-name              "debian.lan";
        option routers                  192.168.100.1;
        default-lease-time              600;
        max-lease-time                  7200;

        zone main.debian.lan. {
                primary 192.168.100.1;
                key "rndc-key";
        }

        zone 100.168.192.in-addr.arpa. {
                primary 192.168.100.1;
                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

DHCP_HOSTNAME=centos

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

nslookup ubuntu01

the command will return the following message:

Server:		192.168.100.1
Address:	192.168.100.1#53

Name:	ubuntu01.debian.lan
Address: 192.168.100.2

Check the reverse dns

nslookup 192.168.100.2

the command will return the following message:

Server:		192.168.100.1
Address:	192.168.100.1#53

2.100.168.192.in-addr.arpa	name = ubuntu01.debian.lan.

Have fun!


Your rating: None Average: 4 (1 vote)
Nutellahase's picture

a good piece of work ....

after working about one day on your solution i discovered, that many problems have their solution within apparmor. I'm was very
suppriesed that many people on the net just turning apparmor off
instead of dealing with it and leaning the new technics. Perhaps
you can write some more Details about DNS/DHCP and DDNS within the "Monster" apparmor. Well, the last failure on my side was a
misconfiguration of the apparmor-File from the bind9. bind9 wasn't able to create or change the jnl-Files in the chrooted /etc/bind folder. A simple change from the permission "r" to "rw" in that file was the solution. take care
that if you have changed the apparmor file to do a: /etc/init.d/apparmord reload an then restart apparmor again, and as you said: Have fun ;-)) ... Thanks for the very good work !

XIEGFRIED's picture

it's a kinnda difrent!

is it ubuntu version or debian! or the retail of two of it?
i just get used to use debian! is there both the same?

sorry for many quetions!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may quote other posts using [quote] tags.

More information about formatting options