Protocol: | UDP |
Standard Port: | 67 |
The dhcpd daemon implements the Dynamic Host Configuration Protocol, an extension of the Bootstrap Protocol (BOOTP). Although originally designed for the purposes of remote booting for diskless workstations, DHCP is a very convenient way to centralize the configuration of network settings for a collection of hosts on a network.
The DHCP server discussed here is the common Internet Software Consortium (ISC) dhcpd. The dhcpd server listens on port 67 to UDP requests broadcast by client hosts on the network. It is designed as a long-running daemon, conventionally started by the system's boot scripts.
Since DHCP is a UDP rather than TCP service, we can't use a tcpserver invocation for startup. But we can still use a daemontools setup to provide the familiar advantages for startup, monitoring, and logging.
A daemontools dhcpd service is very easy to configure. The procedure described here refers specifically to the setup for an OpenBSD (3.4) platform, which includes the dhcpd server as standard equipment. Note that other platforms may require installation of dhcpd as a separate package, with different locations for the executable and configuration files.
First, create the /etc/dhcpd.conf configuration file appropriate for your network. For what it's worth, here is a basic sample. See the dhcpd.conf(5) man page for complete instructions. (If Bernstein wrote a DHCP server, we would have a nice cdb file here instead!)
Then, make the usual local service directories for the dhcpd service:
# mkdir -p /var/svc.d/dhcpd/log
Here is a run
script for
/var/svc.d/dhcpd/run:
#!/bin/sh # dhcpd/run exec 2>&1 echo "*** Starting dhcpd service ..." exec /usr/sbin/dhcpd -f -d \ -cf /etc/dhcpd.conf \ -lf /var/db/dhcpd.leases \ xl1 ### that's all, folks!
Make executable, chmod 755.
The -f option is the crucial foreground
flag,
necessary for the use of daemontools.
The -d option will make dhcpd log to stderr,
rather than syslog, so we can use multilog.
The -cf and -lf options define where
dhcpd should find its configuration and lease files, respectively.
Note: for successful logging of dhcpd, do NOT use the -q option.
Finally, the last argument shown here is xl1
,
the particular interface that dhcpd should listen on for DHCP requests.
Since our particular server is dual-homed,
we want dhcpd to listen only to the side facing the internal network.
(A server with a single interface would not require this argument.)
The usual run
script for the logger in
/var/svc.d/dhcpd/log/run:
#!/bin/sh # dhcpd/log/run exec setuidgid multilog multilog t /var/multilog/dhcpd ### that's all, folks!
Make executable, chmod 755. Prepare the log directory in /var/multilog:
# mkdir -p /var/multilog/dhcpd # chown multilog:nofiles /var/multilog/dhcpd
Link into /service:
# ln -s /var/svc.d/dhcpd /service/dhcpd
After you bring the service up, check the multilog to see that everything looks okay. Then set up client workstations to get their network configuration via dhcp.
Once the clients are setup, sit back at your own terminal with a favorite beverage and take it easy.
Copyright © 2003, 2004 Wayne Marshall.
All rights reserved.
Last edit 2004.09.06, wcm.