DHCP-4.3.1

Introduction to ISC DHCP

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

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

[Note]

Note

Make sure you disable systemd-networkd service or make it not configure the connections you want to manage with DHCP client.

Package Information

Additional Downloads

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 ISC DHCP

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

patch -Np1 -i ../dhcp-4.3.1-missing_ipv6-1.patch
[Note]

Note

Be careful with the instructions below. The single and double quotes are important beecause the defined variables are used verbatim in the code.

Install ISC DHCP by running the following commands:

patch -Np1 -i ../dhcp-4.3.1-client_script-1.patch &&
CFLAGS="-D_PATH_DHCLIENT_SCRIPT='\"/sbin/dhclient-script\"'         \
        -D_PATH_DHCPD_CONF='\"/etc/dhcp/dhcpd.conf\"'               \
        -D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'"        \
./configure --prefix=/usr                                           \
            --sysconfdir=/etc/dhcp                                  \
            --localstatedir=/var                                    \
            --with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases       \
            --with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases     \
            --with-cli-lease-file=/var/lib/dhclient/dhclient.leases \
            --with-cli6-lease-file=/var/lib/dhclient/dhclient6.leases &&
make

To test the results, issue: make check

If you only want to install the ISC DHCP client, issue the following commands as the root user:

make -C client install         &&
mv -v /usr/sbin/dhclient /sbin &&
install -v -m755 client/scripts/linux /sbin/dhclient-script

Skip to the section called “Client Configuration” in order to configure the client

If you only want to install the ISC DHCP server, issue the following command as the root user:

make -C server install

Skip to the section called “Server Configuration” in order to configure the server.

Alternatively, you can install whole package which includes the client, server, relay, static libraries and development headers by running the following commands as the root user:

make install                   &&
mv -v /usr/sbin/dhclient /sbin &&
install -v -m755 client/scripts/linux /sbin/dhclient-script

Configuring ISC DHCP

Config Files

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

Client Configuration

Create basic /etc/dhcp/dhclient.conf by running the following command as the root user:

cat > /etc/dhcp/dhclient.conf << "EOF"
# Begin /etc/dhcp/dhclient.conf
#
# Basic dhclient.conf(5)

#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        netbios-name-servers, netbios-scope, interface-mtu,
        ntp-servers;
require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;

# End /etc/dhcp/dhclient.conf
EOF

See man 5 dhclient.conf for additional options.

Now create the /var/lib/dhclient directory which will contain DHCP Client leases by running the following command as the root user:

install -v -dm 755 /var/lib/dhclient

If you want to configure network interfaces at boot using dhclient, you need to install the systemd unit included in blfs-systemd-units-20140907 package by running the following command as the root user:

make install-dhclient

At this point you can test if dhclient is behaving as expected by running the following command as the root user:

systemctl start dhclient@eth0

To start dhclient on a specific interface at boot, enable the previously installed systemd unit by running the following command as the root user:

systemctl enable dhclient@eth0

Replace eth0 with the actual interface name.

Server Configuration

Note that you only need the DHCP server if you want to issue LAN addresses over your network. The DHCP client doesn't need the server in order to function properly.

Start with creating /etc/dhcp/dhcpd.conf by running the following command as the root user:

cat > /etc/dhcp/dhcpd.conf << "EOF"
# Begin /etc/dhcp/dhcpd.conf
#
# Example dhcpd.conf(5)

# Use this to enble / disable dynamic dns updates globally.
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
  range 10.254.239.10 10.254.239.20;
  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}

# End /etc/dhcp/dhcpd.conf
EOF

Adjust the file to suit your needs. See man 5 dhcpd.conf for additional options.

Now create the /var/lib/dhcpd directory which will contain DHCP Server leases by running the following command as the root user:

install -v -dm 755 /var/lib/dhcpd

To start the dhcpd daemon at boot, install the systemd unit from the blfs-systemd-units-20140907 package by running the following command as the root user:

make install-dhcpd

You will need to edit the /etc/default/dhcpd file in order to set the interface on which dhcpd will serve the DHCP requests.

Contents

Installed Programs: dhclient, dhclient-script, dhcpd, dhcrelay and omshell
Installed Libraries: libdhcpctl.a, libdst.a and libomapi.a
Installed Directories: /etc/dhcp, /usr/include/dhcpctl, /usr/include/isc-dhcp, /usr/include/omapip, /var/lib/dhclient and /var/lib/dhcpd

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 2014-08-23 13:42:03 -0700