DHCP

To run a DHCP server, get the latest version of dhcpd (dhcp-latest.tar.gz) from ftp://ftp.isc.org/isc/dhcp/. Unzip/tar it and run ./configure, followed by make and make install. Note that this isn't the standard configure script so don't try to give it any parameters. They won't work and will just cause the script to crap out.

The make install puts the executables in /usr/local/sbin. If you want them to be in /sbin (where everyone expects to find them), you can either copy them there or symlink them. I prefer the symlink, since when you install the next version of the software into /usr/local/sbin, the newer version will be used instead of the older version hanging around:

     ln -s /usr/local/sbin/dhclient /sbin/dhclient
     ln -s /usr/local/sbin/dhcpd /sbin/dhcpd
     ln -s /usr/local/sbin/dhcrelay /sbin/dhcrelay

/etc/rc.d/init.d/dhcpd:

After you've installed dhcpd, if you'd like it to start automatically at boot time, you need a startup script in /etc/rc.d/init.d/dhcpd. You can use this script:

     #!/bin/sh
     #
     # dhcpd         This shell script takes care of starting and stopping
     #               dhcpd.
     #
     # chkconfig: 2345 65 35
     # description: dhcpd provide access to Dynamic Host Control Protocol.
     # Source function library.
     . /etc/rc.d/init.d/functions
     # Source networking configuration.
     . /etc/sysconfig/network
     . /etc/sysconfig/dhcpd
     # Check that networking is up.
     [ ${NETWORKING} = "no" ] && exit 0
     [ -f /usr/sbin/dhcpd ] || exit 0
     [ -f /etc/dhcpd.conf ] || exit 0
     RETVAL=0
     prog="dhcpd"
     start() {
         # Start daemons.
         echo -n $"Starting $prog: "
         daemon /usr/sbin/dhcpd ${DHCPDARGS}
         RETVAL=$?
         echo
         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
         return $RETVAL
     }
     stop() {
         # Stop daemons.
         echo -n $"Shutting down $prog: "
         killproc dhcpd
         RETVAL=$?
         echo
         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcpd
         return $RETVAL
     }
     # See how we were called.
     case "$1" in
       start)
         start
         ;;
       stop)
         stop
         ;;
       restart|reload)
         stop
         start
         RETVAL=$?
         ;;
       condrestart)
         if [ -f /var/lock/subsys/dhcpd ]; then
             stop
             start
             RETVAL=$?
         fi
         ;;
       status)
         status dhcpd
         RETVAL=$?
         ;;
       *)
         echo $"Usage: $0 {start|stop|restart|condrestart|status}"
         exit 1
     esac
     exit $RETVAL

The permissions should look like:

     -rwxr-xr-x     root     root

If you use the above script or, if a DHCP startup script is already installed on your system, you may turn it on by doing:

     /sbin/chkconfig --add dhcpd
     /sbin/chkconfig dhcpd on

/etc/sysconfig/dhcpd:

Note that the standard startup script or the script supplied above will look in /etc/sysconfig/dhcpd for DHCP parameters. This is so the system admin tools can monkey with DHCP startup parameters. If this file is missing, the script won't start so you'll need to supply one. Here's a sample:

     # Command line options here
     DHCPDARGS=

If you are running the latest version of DHCP, that supports IPV4 and IPV6, you will need to choose one by supplying the correct value to DHCPDARGS. The default (for now) is "-4", which selects IPV4. However, it wouldn't hurt to specify "-4", if you want IPV4, just in case, in the future the code winkies decide to make IPV6 the default and your configuration stops working. If you want IPV6, you must specify "-6".

The file permissions should look like:

     -rw-r--r--     root     root

/etc/dhcpd.conf:

This is the DHCP daemon config file. It should be set up something like:

     authoritative;
     default-lease-time 7200;
     max-lease-time 86400;
     option subnet-mask 255.255.255.0;
     option domain-name-servers 151.203.0.84, 151.203.0.85;
     option domain-name "mydomain.com";
     ddns-update-style ad-hoc;
     subnet 192.168.1.0 netmask 255.255.255.0 {
         option broadcast-address 192.168.1.255;
         option routers 192.168.1.1;
         range 192.168.1.150 192.168.1.200;
     }

You can do "man dhcpd.conf" for a definitive description of how to set up this config file.

Once you've installed the startup script and configured DHCP via its config file, start DHCP via:

     /etc/rc.d/init.d/dhcpd start

/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcp/dhcpd.leases:
/var/state/dhcp/dhcpd.leases:
/var/db/dhcpd.leases:

The first time DHCP is run, it will whine about not being able to find the leases file (/var/lib/dhcpd/dhcpd.leases or, possibly, /var/lib/dhcp/dhcpd.leases for older versions of DHCP, and /var/state/dhcp/dhcpd.leases for newer versions of DHCP or, even, /var/db/dhcpd.leases for the newest versions). You simply need to create an empty file, wherever DHCP is looking for it. For example:

     touch /var/state/dhcpd/dhcpd.leases

The permissions should look like:

     -rw-r--r--     root     root