Linux HOWTOs

About | Home | Search


HOWTO: dhcp
Description: ISC Dynamic Host Configuration Protocol client and server
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# ISC DHCP 4.2.7
# ==============
# Slackware 13.0: dhcp 3.1.2p1
# Slackware 13.1: dhcp 4.1.1
# Slackware 13.37: dhcp 4.2.1-P1
# Slackware 14.0: dhcp 4.2.4-P2
# Slackware 14.1: dhcp 4.2.5-P1

# When upgrading from one DHCP version to another, you may need to blow away
# (or modify) your old leases file due to file format incompatibilities
# between versions.  Check the release notes for differences between the
# version that you're running and the one you're about to install.

# FYI, there are also ESV (extended support versions) now.  If you are
# installing this on a server that is neglected most of the time, that
# may be the way to go.  Only critical bug and security fixes are added to
# those, so you are less likely to have issues due to new features.

# You can find the release notes for the version covered here, and older
# ones' changes as well, here:
# https://kb.isc.org/article/AA-01193/82/DHCP-4.2.7-Release-Notes.html

# Version 4.2.7 is considered "Current-Stable"

# Get it
cd
test -f installed/dhcp-4.2.7.tar.gz &&
 mv installed/dhcp-4.2.7.tar.gz .
test ! -f dhcp-4.2.7.tar.gz &&
 wget http://ftp.isc.org/isc/dhcp/4.2.7/dhcp-4.2.7.tar.gz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "e688bb2fbd4b9017ee4a137785361453  dhcp-4.2.7.tar.gz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "0024f1f96f4a44bdb52dcf3c2b85e44fb452575e  dhcp-4.2.7.tar.gz" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 189CDBC5 > /dev/null 2>&1 || gpg --recv-keys 189CDBC5 ) &&
 wget -nc http://ftp.isc.org/isc/dhcp/4.2.7/\
dhcp-4.2.7.tar.gz.sha512.asc &&
  gpg --verify dhcp-4.2.7.tar.gz.sha512.asc dhcp-4.2.7.tar.gz &&
   rm dhcp-4.2.7.tar.gz.sha512.asc

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "dhcp-*" -exec rm -r {} \;
tar xzvf ~/dhcp-4.2.7.tar.gz
cd dhcp-4.2.7
test $UID = 0 && chown -R root:root .

# Read ./README and ./RELNOTES

# The configure here is now an autoconf one
# I use --disable-dhcpv6 below because I don't use IPv6
# If you don't pass --with-srv-lease-file as below, it will end up as
#  /var/db/dhcpd.leases
# For chroot: --enable-paranoia and --enable-early-chroot
# To build it against your system-wide libbind (from BIND),
#  pass --with-libbind=PATH
#  otherwise it will use ./bind/, which may be easier if your includes are
#  not in the right places...
# For OpenLDAP support: --with-ldap --with-ldapcrypto

# Configure it
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--infodir=/usr/info --mandir=/usr/man --docdir=/usr/doc/dhcp-4.2.7 \
--disable-dhcpv6 \
--with-srv-lease-file=/var/state/dhcp/dhcpd.leases \
--with-cli-lease-file=/var/state/dhcp/dhclient.leases

# Build it
make

# Become root to install it
su

# Back up your existing dhclient.conf, dhcpd.conf, and leases file
# (if it's more than 0 bytes)
mkdir -p -m 0700 ~/backup/dhcp
test -f /etc/dhclient.conf &&
 cp -a /etc/dhclient.conf ~/backup/dhcp/dhclient.conf-$(date +%Y%m%d)
test -f /etc/dhcpd.conf &&
 cp -a /etc/dhcpd.conf ~/backup/dhcp/dhcpd.conf-$(date +%Y%m%d)
test -s /var/state/dhcp/dhcpd.leases &&
 cp -a /var/state/dhcp/dhcpd.leases ~/backup/dhcp/dhcpd.leases-$(date +%Y%m%d)

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg dhcp

# You may have an old /etc/dhclient.conf and /etc/dhcpd.conf left
# over from the Slackware package, and the old /var/state/dhcp
# directory will still be there.  removepkg won't remove those.

## Install the new version
# 'make install' in 4.2.4-P2 blew away my /etc/dhcpd.conf, so make sure
# you really did back up yours above before running it
make install
touch /var/state/dhcp/dhcpd.leases

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

## If you use dhcpd and don't have another script already set to start
## it on boot-up, add something like this to /etc/rc.d/rc.local
## Make sure you read 'man dhcpd' if you don't want it listening to
## all interfaces, or only specific IPs, to run in the foreground, or
## anything like that.
##
# if [ -s /etc/dhcpd.conf -a -x /usr/sbin/dhcpd ]; then
#   echo "Starting dhcpd..."
#   /usr/sbin/dhcpd -q
# fi  

# Check out sample client configuration - ./client/dhclient.conf
# Read 'man dhclient' and 'man dhclient.conf'
#
# Check out sample server configuration - ./server/dhcpd.conf
# Read 'man dhcpd' and 'man dhcpd.conf'
# Make sure you run 'dhcpd -t' before restarting dhcpd :-)

## Here is a sample /etc/dhclient.conf that I used to use with dhclient to
## get a dynamic IP address from my former Internet provider.
#
# interface "eth0" {
#   supersede domain-name "englanders.us";
#   prepend domain-name-servers 192.168.123.2, 192.168.123.1;
#   require subnet-mask, routers;
# }
#
## It causes a few things to be changed in /etc/resolv.conf  It uses my
## domain instead of theirs, and it lists my internal DNS servers
## (192.168.123.x) before theirs (1.2.3.x).  Here's an example of a
## resolv.conf that it creates:
##
## search englanders.us
## nameserver 192.168.123.2
## nameserver 192.168.123.1
## nameserver 1.2.3.4
## nameserver 1.2.3.5
## nameserver 1.2.3.6

# I change around my DHCP server configuration pretty often.  I do not
# currently, but I have at times used dynamic DNS, failover, and other
# total overkill features for my home server.  To figure it all out for
# a client is usually why.  If you would like to see any of my old
# configurations, e-mail me.

# Become yourself again:
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/dhcp-*.tar.*
mv dhcp-4.2.7.tar.gz installed/


# If you ever need to uninstall DHCP, run this to hopefully cover all bases:
su
test -f /etc/dhcpd.conf &&
 ( mkdir -p -m 0700 ~/backup ; mv -f /etc/dhcpd.conf ~/backup/ )
rm -f /usr/bin/omshell /usr/local/include/dhcpctl.h /usr/man/man1/omshell.1
( cd /sbin ; rm -f dhclient dhclient-script )
test -d /usr/local/include/isc-dhcp && rm -r /usr/local/include/isc-dhcp
test -d /usr/local/include/omapip && rm -r /usr/local/include/omapip
( cd /usr/local/lib ; rm -f libdhcpctl.a libomapi.a )
( cd /usr/man/man3 ; rm -f dhcpctl.3 omapi.3 omshell.3 )
( cd /usr/man/man5 ; rm -f dhclient.conf.5 dhclient.leases.5 dhcp-eval.5 \
  dhcp-options.5 dhcpd.conf.5 dhcpd.leases.5 )
( cd /usr/man/man8 ; rm -f dhclient.8 dhclient-script.8 dhcpd.8 dhcrelay.8 )
( cd /usr/sbin ; rm -f dhcpd dhcrelay )
test -d /var/state/dhcp &&
 ( cd /var/state/dhcp ; rm -f dhcpd.leases dhcpd.leases~ )
exit
find ~/src -maxdepth 1 -type d -name "dhcp-*" -exec rm -r {} \;
rm -f ~/installed/dhcp-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>