DHCP-4.2.3

Introduction to DHCP

The DHCP package contains both the client and server programs for DHCP. dhclient (the client) is useful for connecting your computer to a network which uses DHCP to assign network addresses. dhcpd (the server) is useful for assigning network addresses on your private network.

This package is known to build and work properly using an LFS-7.0 platform.

Package Information

Additional Downloads

DHCP Dependencies

Required

Net-tools-1.60 is required at runtime by dhclient if you do not use the iproute2 patch.

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/dhcp

Kernel Configuration

You must have Packet Socket support (Networking Support ⇒ Networking Options ⇒ Packet Socket) compiled into the kernel. If you do not have IPv6 support (Networking Support ⇒ Networking Options ⇒ The IPv6 Protocol) compiled in, then you must use the missing_ipv6 patch.

Installation of DHCP

If you have not compiled IPv6 support into the kernel, apply the missing_ipv6 patch

patch -Np1 -i ../dhcp-4.2.3-missing_ipv6-1.patch

If you are installing the client, apply the iproute2 patch unless you will have installed net-tools by the time you wish to use the client:

patch -Np1 -i ../dhcp-4.2.3-iproute2-1.patch

Install DHCP by running the following commands:

sed -i 's%\(^sbindir =\).*%\1 @prefix@@sbindir@%' server/Makefile.in &&
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
 --sbindir=/sbin \
  --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \
   --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \
    --with-cli-lease-file=/var/state/dhclient.leases \
     --with-cli6-lease-file=/var/state/dhclient6.leases  &&
sed -i 's/-Werror//' {client,common,dst,omapip,relay,server,tests}/Makefile

If you only wish to build the server, enter:

sed -i 's/ client//' Makefile

If you only wish to build the client, enter:

sed -i 's/ dhcpctl relay server//' Makefile

Build your chosen variant(s) with:

make

To test the results, issue: make check

Now, as the root user:

make install

The supplied /etc/dhcpd.conf (server) and /etc/dhclient.conf (client) are examples for a specific BSD system. They are unlikely to be appropriate to your needs, but you may wish to read them for ideas before deleting them or moving them to a different location.

Now create the director(y,ies) for the leases.

For the server:

mkdir -pv /var/state/dhcp

For the client:

mkdir -pv /var/state

Command Explanations

sed -i 's%\(^sbindir =\).*%\1 @prefix@@sbindir@%' server/Makefile.in This command moves the dhcp program to /usr/sbin instead of /sbin because it is not needed while the server is booting.

--sbindir=/sbin The dhclient program is moved to /sbin instead of /usr/sbin so that it is available during boot, e.g. if /usr is to be an nfs mount.

--with-*-lease-files=... By default, lease files are placed in /var/db which is an anachronism.

sed -i 's/-Werror//' {client,common,...}/Makefile - the Makefiles in this package add -Werror to the CFLAGS. On recent versions of gcc more things, particularly unused variables, create warnings. The -Werror flag causes warnings to break the build, so we remove it where necessary.

sed -i 's/ something//' Makefile - this stops the build from entering the director(y,ies) named here.

rm -v /usr/lib/lib{dhcpctl,dst,omapi}.a - there is no easy way to prevent these static libraries being installed, but they are only needed during the build of this package. libdhcpctl.a is only installed if you build the server.

Configuring DHCP

Config Files

/etc/dhclient.conf and /etc/dhcpd.conf

Configuration Information

Information on configuring the DHCP client can be found in Chapter 13, Connecting to a Network.

Note that you only need the DHCP server if you want to issue LAN addresses over your network. The DHCP client doesn't need this script to be used. Also note that this script is coded for the eth1 interface, which may need to be modified for your hardware configuration.

Install the /etc/rc.d/init.d/dhcp init script included in the blfs-bootscripts-20111226 package.

make install-dhcp

The lease file must exist on startup. The following command will satisfy that requirement:

touch /var/state/dhcp/dhcpd.leases

The following commands will create a base configuration file for a DHCP server. There are several options that you may want to add (information that is passed back to the DHCP client) and those are covered in the man pages for dhcp.conf.

cat > /etc/dhcpd.conf << "EOF"
default-lease-time 72000;
max-lease-time 144000;

subnet <192.168.5.0> netmask <255.255.255.0> {
  range <192.168.5.10> <192.168.5.240>;
  option broadcast-address <192.168.5.255>;
  option routers <192.168.5.1>;
}
EOF

All addresses should be changed to meet your circumstance.

Contents

Installed Programs: dhcpd, dhcrelay, dhclient, dhclient-script, and omshell
Installed Libraries: libbdhcpctl.a, libdst.a, libomapi.a
Installed Directories: /var/state/dhcp, /usr/include/omapip, and /usr/include/isi-dhcp

Short Descriptions

dhclient

is the implementation of the DHCP client.

dhclient-script

is used by dhclient to (re)configure interfaces. It can make extra changes by invoking custom dhclient-{entry,exit}-hooks.

dhcpd

implements Dynamic Host Configuration Protocol (DHCP) and Internet Bootstrap Protocol (BOOTP) requests for network addresses.

dhcrelay

provides a means to accept DHCP and BOOTP requests on a subnet without a DHCP server and relay them to a DHCP server on another subnet.

omshell

provides an interactive way to connect to, query, and possibly change, the ISC DHCP Server's state via OMAPI, the Object Management API.

Last updated on 2011-12-01 05:09:32 +0000