DHCP Server Configuration(dhcpd)

DHCP (Dynamic Host Configuration Protocol) is used to control the Internet networking parameters of hosts with the help of a server. DHCP is backward compatible with BOOTP (which has mostly replaced RARP), which is mostly used for diskless workstations (and X terminals). DHCP is documented in RFC 2131.

The basic operation is very simple.A client host sends a DHCP broadcast packet out when bringing up networking.A DHCP server responds to the client, providing it information such as its IP address(es) and mask, gateway address, default domain, hostname, DNS addresses, and possibly other information.

The client hostís DHCP broadcast packet contains its MAC address (thatís all it knows), to port UDP/68.A DHCP server responds (hopefully, if you have configured your firewalls correctly!)Note that some routers may require special configuration, to forward such broadcasts from one LAN to the LAN containing a DCHP server.(Cisco calls these IP helper addresses.)

The client can accept this information and configure networking accordingly, however clients can override some or all of that information with local configuration.

The server provides the information for a limited time only.This is called the lease.Once the lease has expired, the server may re-assign the client hostís IP address(es) to other clients.A client can renew the lease, if the server permits it.A client can also release (give up) its lease early.The lease period can be configured for minutes, hours, days, or permanently.

By associating the network information with the clientís MAC address, DHCP can be used to assign static IP addresses as well. This use centralizes configuration informaion.

You can run the DHCP client program manually any time.Fedora Core 4 uses the ISC client dhclient.This tool is simple to use:

dhclient options interface

By default it looks for /etc/dhclient.conf to see what information it should accept.To keep track of lease information for all interfaces between reboots, it stores that information in dhclient.leases.For example:

dhclient ††††††††# configure all interfaces

dhclient -d eth0 # configure eth0 only, run in
†††††††††††††††† # the foreground (debug mode)

dhclient -r eth0 # release the lease for eth0

Related client tools (also from ISC) are omshell, which allows you to examine and modify the in-memory dhclient lease information, and dhclient‑script, which is a helper script invoked by dhclient.

There are many different DHCP servers available: pump, dhcpcd, etc.Fedora Core 4 ships with dhcpd from the Internet Systems Consortium (ISC), which can handle BOOTP as well.

dhcp.leases- create empty if not present:

touch /var/lib/dhcp/dhcpd.leases

/etc/dhcpd.conf - see man page and the example below.

First make sure you have installed a DHCP server.One way to tell is to look for the program "dhcpd" or the file /etc/rc.d/init.d/dhcpd.You will need to make sure the server is started automatically at boot time.Use a GUI tool for this, or ntsysv", or "chkconfig", or create the required symbolic (soft) links by hand in /etc/rc.d/rc5.d (or whatever run-level you use).MAKE SURE the dhcpd starts after networking has been brought up!

Configure the file /etc/dhcp.conf to something like this:

1.          subnet netmask {

2.          option routers;

3.          option subnet-mask;

4.          option broadcast-address;

5.          option domain-name-servers;

6.          option domain-name "gcaw.org";

7.          max-lease-time 2592000;

8.          default-lease-time 604800;

9.          range;

10.     }

Line 1 identifies the LAN from which the configuration rules apply.Line 2 through line 6 say what information to provide hosts: a default gateway, a subnet mask, the broadcast address, the IP address of one (or more) DNS servers, and the default domain (search domain) to use.

Lines 7 and 8 give a default lease time of one week and a max of 1 month.The default is one day.(The value is in seconds.)

Other options that can be specified include setting a default domain name, print server, NNTP server, SMTP server, POP server, and timezone, among many other options. Consult the man page for a list.

Line 9 defines the pool of dynamic IP addresses to use.


DHCP can be used to assign dynamic IP addresses to servers. In this case the serverís DNS information must be dynamically updated to reflect the current IP address. Dynamic DNS is supported by BIND (named) version 9 and allows such use. Note that such addresses should never be cached for very long (or at all).

To prevent dhcpd from responding to requests from eth0:0 you must modify the dhcpd command line to something like:

dhcpd -q eth0:0

These cmd line args can also be specified in /etc/sysconfig/dhcpd:

DHCPDARGS='-q eth0:0'

(The ď-qĒ suppresses printing the copyright message.)

A final note:Some Windows clients have trouble using a limited broadcast address.If(and only if) you see this problem, add a static route to your DHCP server if serving any Windows clients:

††† echo ' local-broadcast' >> /etc/hosts
††† route add -host local-broadcast eth0

Solaris:see /usr/sadm/admin/bin/dhcpmgr.