Introduction to dhcpcd

dhcpcd is an implementation of the DHCP client specified in RFC2131. A DHCP client is useful for connecting your computer to a network which uses DHCP to assign network addresses. dhcpcd strives to be a fully featured, yet very lightweight DHCP client.

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

Package Information

dhcpcd Dependencies


LLVM-14.0.6 (with Clang), ntp-4.2.8p15, chronyd, and ypbind

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/dhcpcd

Installation of dhcpcd

Recent releases of dhcpcd implement privilege separation. Additional installation steps are necessary to set up the proper environment, which are performed by issuing the following commands as the root user:

install  -v -m700 -d /var/lib/dhcpcd &&

groupadd -g 52 dhcpcd        &&
useradd  -c 'dhcpcd PrivSep' \
         -d /var/lib/dhcpcd  \
         -g dhcpcd           \
         -s /bin/false     \
         -u 52 dhcpcd &&
chown    -v dhcpcd:dhcpcd /var/lib/dhcpcd 

Fix a runtime error caused by a change in glibc-2.36:

sed '/Deny everything else/i SECCOMP_ALLOW(__NR_getrandom),' \
    -i src/privsep-linux.c

Install dhcpcd by running the following commands:

./configure --prefix=/usr                \
            --sysconfdir=/etc            \
            --libexecdir=/usr/lib/dhcpcd \
            --dbdir=/var/lib/dhcpcd      \
            --runstatedir=/run           \
            --privsepuser=dhcpcd         &&

To test the results, issue: make test.

Now, as the root user:

make install

Command Explanations

--libexecdir=/usr/lib/dhcpcd: Set a more proper location for dhcpcd internal libraries.

--dbdir=/var/lib/dhcpcd: The default /var/db is not FHS-compliant

--runstatedir=/run: The default /var/run is a symbolic link to /run.

--with-hook=...: You can optionally install more hooks, for example to install some configuration files such as ntp.conf. The set of hooks is in the dhcpcd-hooks directory in the build tree.

Configuring dhcpcd

Config Files


General Configuration Information

To configure dhcpcd, you need to first install the network service script, /usr/lib/services/dhcpcd included in the blfs-bootscripts-20220722 package (as user root):

make install-service-dhcpcd


the network service script /usr/lib/services/dhcpcd contained in bootscripts up to blfs-bootscripts-20191204 is not compatible with latest dhcpcd, as the location of the pidfile changed. To work around this, issue the following command:

sed -i "s;/run/dhcpcd-;/run/dhcpcd/;g" /lib/services/dhcpcd


The default for dhcpcd is to set the hostname and mtu. It also overwrites /etc/resolv.conf and /etc/ntp.conf. These modifications to system files are done by hooks which are stored in /usr/lib/dhcpcd/dhcpcd-hooks. Setup dhcpcd by removing or adding hooks from/to that directory. The execution of hooks can be disabled by using the --nohook (-C) command line option or by the nohook option in the /etc/dhcpcd.conf file.

Finally, as the root user create the /etc/sysconfig/ifconfig.eth0 configuration file using the following commands. Adjust appropriately for additional interfaces:

cat > /etc/sysconfig/ifconfig.eth0 << "EOF"
DHCP_START="-b -q <insert appropriate start options here>"
DHCP_STOP="-k <insert additional stop options here>"

For more information on the appropriate DHCP_START and DHCP_STOP values, examine the man page for dhcpcd.

Configuration Information: fixed ip

Although not usual, it is possible that you need to configure dhcpcd to use a fixed ip. Here, we give an example. As the root user create the /etc/sysconfig/ifconfig.eth0 configuration file using the following commands. Adjust appropriately for additional interfaces and for the actual ip and router you need:

cat > /etc/sysconfig/ifconfig.eth0 << "EOF"
DHCP_START="-b -q -S ip_address= -S routers="

You can either use DNS servers in /etc/resolv.conf from another system, your preferred servers, or just the example /etc/resolv.conf.head file below as is:

cat > /etc/resolv.conf.head << "EOF"
# OpenDNS servers


Installed Program: dhcpcd
Installed Library: /usr/lib/dhcpcd/dev/udev.so
Installed Directory: /{usr,var}/lib/dhcpcd and /usr/share/dhcpcd

Short Descriptions


is an implementation of the DHCP client specified in RFC2131


adds udev support for interface arrival and departure; this is because udev likes to rename the interface, which it can't do if dhcpcd grabs it first