dhcpcd-10.0.6

dhcpcd の概要

dhcpcd は、RFC2131 にて定義されている DHCP クライアントの実装です。 DHCP クライアントは、DHCP を利用してネットワークアドレスが割り当てられたネットワークへのアクセスに用いられます。 dhcpcd は十分な機能を有すると同時に、大変軽量な DHCP クライアントです。

[注記]

注記

LFS や依存パッケージが本ブックに示す最新安定バージョンでなかった場合には、BLFS 開発版においては、パッケージのビルドや処理実行が適切に行われないことがあります。

パッケージ情報

dhcpcd の依存パッケージ

任意

LLVM-17.0.6 (with Clang), ntp-4.2.8p17, chronyd, and ypbind

Privilege separation

Recent releases of dhcpcd optionally support privilege separation. As the practical security benefits of this are unclear for a program like dhcpcd and the setup is more complicated, the book currently defaults to disable it.

If you however would like to use privilege separation, additional installation steps are necessary to set up the proper environment. Issue 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 

dhcpcd のインストール

Build dhcpcd without privilege separation by running the following command:

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

Alternatively, build dhcpcd with privilege separation by running the following commands:

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

ビルド結果をテストする場合は make test を実行します。

root ユーザーになって以下を実行します。

make install

コマンド説明

--libexecdir=/usr/lib/dhcpcd: This switch sets a better location for the dhcpcd internal libraries.

--dbdir=/var/lib/dhcpcd: This switch adjusts the database directory because the default directory, /var/db, is not FHS-compliant.

--runstatedir=/run: This switch sets the runtime state directory because the default /var/run is a symbolic link to /run, and using /var/run is deprecated.

--disable-privsep: This switch disables privilege separation, which is the default in dhcpcd. This switch is not used in the build configuration where privilege separation is used.

--privsepuser=dhcpcd: This switch sets the privilege separation user in the build configuration where privilege escalation is used.

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

dhcpcd の設定

設定ファイル

/etc/dhcpcd.conf

全般的な設定情報

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

make install-dhcpcd
[注記]

注記

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 /usr/lib/dhcpcd/dhcpcd-hooks. You can change this behavior 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.

[注記]

注記

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.

パッケージ構成

インストールプログラム: dhcpcd
インストールライブラリ: /usr/lib/dhcpcd/dev/udev.so
インストールディレクトリ: /{usr,var}/lib/dhcpcd, /usr/share/dhcpcd

概略説明

dhcpcd

RFC2131 にて定義されている DHCP クライアントの実装です。

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