我有 3 个运行内核 5.15 和 systemd 版本 250.5+ 的 Linux 机器。
我有一个盒子作为 BATMAN 网格主机运行,并有一个由 SystemD 管理的 DHCP 服务器,另外两个是网格客户端。
我希望 DHCP 服务器根据网状客户端的 Mac 地址为其分配一个 IP 地址。我不希望他们根据 IAID/DUID 分配 IP。为此,文档说使用客户端标识符=mac,我已经做到了。问题是我看到分配给我的客户端的多个 IP 地址,有些基于 mac 地址,有些显然基于 DUID。
如何从 systemd-networkd 配置 DHCP 服务器以仅使用 BATMAN 遵守客户端标识符 mac?谢谢。
master 上的 bat0.network 文件如下所示:
root@mesh-master:/etc/systemd/network# cat bat0.network
[Match]
Name=bat0
[Network]
Address=10.10.10.1/24
DHCPServer=true
[DHCPV4]
DUIDType=link-layer
ClientIdentifier=mac
[DHCPServer]
PoolOffset=10
PoolSize=8
EmitsDNS=yes
DNS=8.8.8.8
EmitNTP=yes
NTP=10.10.10.1
Networkctl 网格主状态:
root@mesh-master:~# networkctl status bat0
● 6: bat0
Link File: n/a
Network File: /etc/systemd/network/bat0.network
Type: ether
State: routable (configured)
Online state: online
Driver: B.A.T.M.A.N. advanced
Hardware Address: 66:4e:8d:94:88:b7
MTU: 1500 (min: 68, max: 1500)
QDisc: noqueue
IPv6 Address Generation Mode: eui64
Queue Length (Tx/Rx): 1/1
Address: 10.10.10.1
169.254.12.198
fe80::644e:8dff:fe94:88b7
fe80::d061:ecd7:c3fd:aef1
Activation Policy: up
Required For Online: yes
DHCP6 Client DUID: DUID-EN/Vendor:0000ab113a78856d82eaf5680000
Offered DHCP leases: 10.10.10.13 (to a6:d2:9c:dc:0c:61)
10.10.10.14 (to IAID:0x9cdc0c61/DUID)
10.10.10.17 (to IAID:0x127060c/DUID)
10.10.10.15 (to IAID:0x127060c/DUID)
10.10.10.12 (to 5a:e6:01:27:06:0c)
10.10.10.16 (to IAID:0x127060c/DUID)
客户端网络文件(bat0.network):
root@mesh-client:~# cat /etc/systemd/network/bat0.network
[Match]
Name=bat0
[Network]
DHCP=ipv4
[DHCP]
ClientIdentifier=mac
网格客户端上的 Networkctl 状态 bat0:
root@mesh-client:~# networkctl status bat0 -l
● 6: bat0
Link File: n/a
Network File: /etc/systemd/network/bat0.network
Type: ether
State: routable (configured)
Online state: online
Driver: B.A.T.M.A.N. advanced
Hardware Address: a6:d2:9c:dc:0c:61
MTU: 1500 (min: 68, max: 1500)
QDisc: noqueue
IPv6 Address Generation Mode: eui64
Queue Length (Tx/Rx): 1/1
Address: 10.10.10.13 (DHCP4 via 10.10.10.1)
10.10.10.14
fe80::1273:a607:f897:6bd3
fe80::a4d2:9cff:fedc:c61
Gateway: 10.10.10.1
10.10.10.1
DNS: 8.8.8.8
NTP: 10.10.10.1
Activation Policy: up
Required For Online: yes
Time Zone: UTC
DHCP4 Client ID: a6:d2:9c:dc:0c:61
DHCP6 Client DUID: DUID-EN/Vendor:0000ab11482afb1e3d85f23a0000
Mar 30 16:06:07 iot-gate-imx8plus systemd-networkd[459]: bat0: Link UP
Mar 30 16:06:07 iot-gate-imx8plus systemd-networkd[459]: bat0: Gained carrier
Mar 30 16:06:09 iot-gate-imx8plus systemd-networkd[459]: bat0: Gained IPv6LL
Mar 30 16:06:15 iot-gate-imx8plus systemd-networkd[459]: bat0: DHCPv6 lease lost
Mar 30 16:06:16 iot-gate-imx8plus systemd-networkd[726]: bat0: netdev ready
Mar 30 16:06:16 iot-gate-imx8plus systemd-networkd[726]: bat0: Link UP
Mar 30 16:06:16 iot-gate-imx8plus systemd-networkd[726]: bat0: Gained carrier
Mar 30 16:06:16 iot-gate-imx8plus systemd-networkd[726]: bat0: Gained IPv6LL
Mar 30 16:06:16 iot-gate-imx8plus systemd-networkd[726]: bat0: netdev exists, using existing without changing its parameters
Mar 30 16:06:47 iot-gate-imx8plus systemd-networkd[726]: bat0: DHCPv4 address 10.10.10.13/24, gateway 10.10.10.1 acquired from 10.10.10.1