Setting up Linux DHCP Server with Dynamic DNS Support

August 8, 2004, updated August 8, 2004

This tutorial will explain how to setup DHCP to dynamically update a local DNS server. I use Red Hat/Fedora but these are common steps you'll have to use with just about any flavor of these Linux services.

Setting up the Server

For starters, lets configure the /etc/dhcpd.conf file. It's pretty self explanitory. If you are planning on setting up a local DNS server leave in the 3 lines pertaining to Dynamic DNS, otherwise take them out.

# Global Settings
# Turn on Dynamic DNS:
ddns-domainname "domain.lan";
ddns-update-style interim;
ddns-updates on;
# Don't allow clients to update DNS, make the server do it
# based on the hostname passed by the DHCP client:
deny client-updates;
allow unknown-clients;
# Scope Settings
subnet netmask {
        # Range of DHCP assigned addresses for this scope
        range                 ;
        # 1 day
        default-lease-time              86400;
        # 2 days
        max-lease-time                  172800;
        # Configure the client's default Gateway:
        option subnet-mask    ;
        option broadcast-address;
        option routers        ;
        # Configure the client's DNS settings:
        option domain-name              "domain.lan";
        option domain-name-servers;

Now things get a little tricky. If you have Windows clients you are going to need to modify the /etc/rc.d/init.d/dhcpd file. In the start() directive you should see a line that looks something like

daemon /usr/sbin/dhcpd ${DHCPDARGS}

Comment that out with a # and add in the following lines. If you want, add in the DHCPDARGS also, but I don't really use it.

/sbin/route add -host dev eth0 2> /dev/null
daemon /usr/sbin/dhcpd eth0

Make sure you set the ethx to the network interface you want to serve dhcpd requests on. This is particularly vital if you have a multihomed server.

Setting up the Client

The client needs to send a hostname for this to work correctly. The DHCP server needs to know what hostname to set in DNS. Windows does it by default, however you'll need to make sure your /etc/sysconfig/network-scripts/ifcfg-ethx file looks something like this (with the DHCP_HOSTNAME directive set properly.

# make sure this line is has no settings on it!

Now, you should go have a beer and explain what you just did to your girlfriend.

Related Posts


Comment February 11, 2005 by anonymous
Comment March 19, 2005 by anonymous
nice article! what about the different startup -script for the dhcp-server when using windows and linux - clients? greetings, dave (dave at dgx dot de
Comment March 23, 2005 by anonymous
I have read lots of docs and this one provided the key to making DDNS work on my system. Thank you so much!
Comment August 13, 2013 by anonymous
I have problem with the last step ... she won't get it :)