Skip to content

Instantly share code, notes, and snippets.

@buzztaiki
Last active January 17, 2026 08:28
Show Gist options
  • Select an option

  • Save buzztaiki/39fe573b9021c07b43bade95862b16c6 to your computer and use it in GitHub Desktop.

Select an option

Save buzztaiki/39fe573b9021c07b43bade95862b16c6 to your computer and use it in GitHub Desktop.
systemd-networkd を使っているときに aterm で DHCP 固定割当できるようにする

systemd-networkd を使っているときに aterm で DHCP 固定割当できるようにする

なぜか固定できなくてはまったのでメモ。

systemd-networkd のデフォルト設定では、DHCP クライアント ID として MAC アドレスではなく DUID (NIC ではなくデバイスごとに固有の ID で /etc/machine/id を元に生成される) を使っている。

https://man.archlinux.org/man/networkd.conf.5#%5BDHCPV4%5D_SECTION_OPTIONS

ClientIdentifier= Specifies the default DHCPv4 client identifier to be used. Takes one of mac or duid. If set to mac, the MAC address of each link will be used. If set to duid, an RFC4361-compliant Client ID, which is the combination of IAID and DUID, is used. IAID can be configured by IAID= in each matching .network file. DUID can be configured by DUIDType= and DUIDRawData=. Defaults to duid.

そのため、DHCP 固定割り当ての画面で MAC アドレスを入力しても固定されない。この画面では MAC アドレスしか受け付けてくれないので DUID のまま頑張ろうとしてもどうにもならない。

そのため /etc/systemd/networkd.conf に以下を書いて、クライアント ID として MAC アドレス使うようにすれば問題が解消する (/etc/systemd/network/*.network で iface ごとに設定しても良い):

[DHCPv4]
ClientIdentifier=mac

その後以下を実行すれば割り当てた IP アドレスになってくれる:

% sudo systemctl restart systemd-networkd.service
% sudo networkctl renew wlan0

クライアント ID や DUID については以下が分かりやすかった:

DHCP固定割当とかClientIdentifierとかRFC2131とか

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment