Last week, we looked at the beginnings of setting up a dynamic DNS service where one could connect any system to the network, have it provide a DHCP-delivered IP address, and automatically set up the forward and reverse DNS names for the system. In particular, the previous tip concentrated on configuring BIND, the DNS server.

In this final tip, we configure ISC’s DHCPd service, which will serve the DHCP-based IP addresses to clients and update the DNS records accordingly. Again, this setup is based on a CentOS 5.3 configuration, but with perhaps minor path changes, it will work on any Linux distribution. As well, in our previous example, we used the home network domain name “home.lan” and the IP address network

The dhcpd configuration file is typically /etc/dhcpd.conf. This file provides all the runtime options to dhcpd, allows you to configure different options for different subnets, and allows you to assign static IP addresses based on the requesting system’s MAC address. Configuring dhcpd fully is beyond the scope of this tip, so we will concentrate primarily on the dynamic DNS related pieces.

At the top of /etc/dhcpd.conf, ensure the following keywords are defined:

ddns-update-style interim;
ddns-updates on;
ddns-domainname "home.lan.";
ddns-rev-domainname "";
use-host-decl-names on;
allow client-updates;
allow unknown-clients;
include "/etc/rndc.key";
zone home.lan. {
        key rndckey;
zone {
        key rndckey;

What the above does is define a variety of options to enable dynamic DNS updates. It also defines our two DNS zones: the reverse lookup zone and the home.lan domain name. Finally, it indicates to use the “rndckey” as defined in /etc/rndc.key (see part 1 for more details on the RNDC key), and indicates that the primary DNS server is — the IP our named server is listening on. If the DHCP server is on the same system as the DNS server, you can use instead; however, ensure that named is configured to listen on the IP address, port 53.

If you also configure static IPs to systems based on their MAC address, you can write host stanzas with hostname information. This ensures that regardless of what the connecting system reports as a hostname, it will use a specific pre-determined hostname. There are two ways this can be done, actually; the first is to define the host statement with the additional dynamic DNS options, such as:

host tyr {
        hardware ethernet 00:0c:eb:20:dc:fe;
        option host-name "tyr";
        DDNS-hostname "tyr";

This tells dhcpd to map the hostname tyr.home.lan to the system with the specified MAC address. It will also statically assign the IP every time, and also tells dhcpd to report the hostname as tyr to named when the system connects.

The other option is to define the above without the option host-name and DDNS-hostname keywords. Instead you can provide A and PTR records in your named zone files for this host.

Once both named and dhcpd are configured, restart both services. At this point you will be able to connect any system to the network, and if you watch the logs (such as /var/log/messages), you will see the “conversation” between named and dhcpd as dhcpd hands out IP addresses to client systems.

Get the PDF version here. (PDF version part1)

Delivered each Tuesday, TechRepublic’s free Linux and Open Source newsletter provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!