#### Beyond Linux® From Scratch (systemd Edition) - Version 11.1

### Chapter 14. Connecting to a Network

- Prev

  Advanced Network Setup

- Next

  DHCP-4.4.2-P1

- Up
- Home

# dhcpcd-9.4.1

## 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.1 platform.

### Package Information

- Download (HTTP): https://roy.marples.name/downloads/dhcpcd/dhcpcd-9.4.1.tar.xz

- Download MD5 sum: 2b2f46648bc96979f96127f0e0e07d9b

- Download size: 251 KB

- Estimated disk space required: 3.6 MB (with tests)

- Estimated build time: less than 0.1 SBU (with tests)

### dhcpcd Dependencies

#### Optional

LLVM-13.0.1 (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

Install dhcpcd by running the following commands:

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

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

`/etc/dhcpcd.conf`

###

#### General Configuration Information

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

    make install-dhcpcd

### Note

The default behavior of dhcpcd is to set the hostname and the mtu. It also overwrites `/etc/resolv.conf` and `/etc/ntp.conf`. These modifications to system configuration files are done by hooks which are stored in `/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.

### Note

Make sure that you disable the systemd-networkd service or configure it not to manage the interfaces you want to manage with dhcpcd.

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

    systemctl start dhcpcd@eth0

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

    systemctl enable dhcpcd@eth0

Replace `eth0` with the actual interface name.

## Contents

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

### Short Descriptions

dhcpcd | is an implementation of the DHCP client specified in RFC2131
`udev.so` | 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

Last updated on

- Prev

  Advanced Network Setup

- Next

  DHCP-4.4.2-P1

- Up
- Home