Linux
systemd-networkd 配置未添加任何路由且未完成配置
在 Debian 10 上使用 systemd 241,我正在嘗試為邊緣伺服器配置 systemd-networkd 樣式的網路。
我遇到的問題是,
systemd-networkd
啟動時,它沒有添加 v4 或 v6 路由,但報告它仍處於“配置”狀態:IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 eth0 ether carrier configuring 3 eth1 ether carrier configuring 6 docker0 bridge routable unmanaged 8 veth9a70b3d ether degraded unmanaged 32 ext bond routable configuring 33 int vlan routable configured
以下是啟動時的調試日誌
networkd
:Aug 23 17:15:52 te1a systemd[1]: Started Network Service. Aug 23 17:15:52 te1a systemd-networkd[29413]: ext: Created Aug 23 17:15:52 te1a systemd-networkd[29413]: ext: Link state is up-to-date Aug 23 17:15:52 te1a systemd-networkd[29413]: No virtualization found in DMI Aug 23 17:15:52 te1a systemd-networkd[29413]: No virtualization found in CPUID Aug 23 17:15:52 te1a systemd-networkd[29413]: Virtualization XEN not found, /proc/xen does not exist Aug 23 17:15:52 te1a systemd-networkd[29413]: This platform does not support /proc/device-tree Aug 23 17:15:53 te1a systemd-networkd[29413]: UML virtualization not found in /proc/cpuinfo. Aug 23 17:15:53 te1a systemd-networkd[29413]: This platform does not support /proc/sysinfo Aug 23 17:15:53 te1a systemd-networkd[29413]: Found VM virtualization none Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: found matching network '/etc/systemd/network/ext.network' Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Setting address genmode for link Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Enslaving by 'int' Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Creating Aug 23 17:15:53 te1a systemd-networkd[29413]: veth9a70b3d: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: veth9a70b3d: found matching network '/etc/systemd/network/veth.network ' Aug 23 17:15:53 te1a systemd-networkd[29413]: veth9a70b3d: Unmanaged Aug 23 17:15:53 te1a systemd-networkd[29413]: docker0: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: docker0: Unmanaged Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: found matching network '/etc/systemd/network/eth1.network' Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Setting address genmode for link Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Enslaving by 'ext' Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Enslaving link 'eth1' Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: found matching network '/etc/systemd/network/eth0.network' Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Setting address genmode for link Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Enslaving by 'ext' Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Enslaving link 'eth0' Aug 23 17:15:53 te1a systemd-networkd[29413]: lo: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: lo: Unmanaged Aug 23 17:15:53 te1a systemd-networkd[29413]: int: New device has no master, continuing without Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Flags change: +MULTICAST +BROADCAST Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Link 33 added Aug 23 17:15:53 te1a systemd-networkd[29413]: int: udev initialized link Aug 23 17:15:53 te1a systemd-networkd[29413]: int: netdev has index 33 Aug 23 17:15:53 te1a systemd-networkd[29413]: int: netdev ready Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Saved original MTU: 1500 Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Joined netdev Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Bringing link up Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: MAC address: 02:f9:36:9d:17:aa Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Flags change: +SLAVE +UP Aug 23 17:15:53 te1a systemd-networkd[29413]: LLDP: Started LLDP client Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Started LLDP. Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Joined netdev Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: MAC address: 02:f9:36:9d:17:aa Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Flags change: +SLAVE +UP Aug 23 17:15:53 te1a systemd-networkd[29413]: LLDP: Started LLDP client Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Started LLDP. Aug 23 17:15:53 te1a systemd-networkd[29413]: eth0: Joined netdev Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Flags change: +LOWER_UP +RUNNING Aug 23 17:15:53 te1a systemd-networkd[29413]: eth1: Gained carrier Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Link state is up-to-date Aug 23 17:15:53 te1a systemd-networkd[29413]: int: found matching network '/etc/systemd/network/int.network' Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Setting address genmode for link Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Bringing link up Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Flags change: +UP Aug 23 17:15:53 te1a systemd-networkd[29413]: LLDP: Started LLDP client Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Started LLDP. Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Flags change: +UP +LOWER_UP Aug 23 17:15:53 te1a systemd-networkd[29413]: LLDP: Started LLDP client Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Started LLDP. Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Flags change: +RUNNING Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Gained carrier Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Setting addresses Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Flags change: +LOWER_UP +RUNNING Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Gained carrier Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Setting addresses Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Updating address: 10.0.1.210/24 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Updating address: 2001:db8:2:100::d2/64 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: int: Addresses set Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Updating address: 192.0.2.196/27 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Updating address: 2001:db8:0:ff01::c4/64 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Updating address: 192.0.2.217/32 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Updating address: 2001:db8:0:ff01::d9/128 (valid forever) Aug 23 17:15:53 te1a systemd-networkd[29413]: ext: Addresses set Aug 23 17:15:54 te1a systemd-networkd[29413]: eth0: Flags change: +LOWER_UP +RUNNING Aug 23 17:15:54 te1a systemd-networkd[29413]: eth0: Gained carrier Aug 23 17:15:55 te1a systemd-networkd[29413]: ext: Adding address: fe80::f9:36ff:fe9d:17aa/64 (valid forever) Aug 23 17:15:55 te1a systemd-networkd[29413]: ext: Gained IPv6LL Aug 23 17:15:55 te1a systemd-networkd[29413]: int: Adding address: fe80::f9:36ff:fe9d:17aa/64 (valid forever) Aug 23 17:15:55 te1a systemd-networkd[29413]: int: Gained IPv6LL Aug 23 17:15:55 te1a systemd-networkd[29413]: ext: Updating address: 2001:db8:0:ff01::d9/128 (valid forever) Aug 23 17:15:55 te1a systemd-networkd[29413]: int: Updating address: 2001:db8:0:100::d2/64 (valid forever) Aug 23 17:15:55 te1a systemd-networkd[29413]: int: Configured Aug 23 17:15:55 te1a systemd-networkd[29413]: ext: Updating address: 2001:db8:0:ff01::c4/64 (valid forever) Aug 23 17:15:56 te1a systemd-networkd[29413]: LLDP: Invoking callback for 'added' event. Aug 23 17:15:56 te1a systemd-networkd[29413]: LLDP: Successfully processed LLDP datagram. (repeats)
這裡是配置文件:
# eth0.network [Match] Name=eth0 [Link] RequiredForOnline=no [Network] Bond=ext
# eth1.network [Match] Name=eth1 [Link] RequiredForOnline=no [Network] Bond=ext
# ext.netdev [NetDev] Name=ext Kind=bond [Bond] Mode=802.3ad MIIMonitorSec=0.1 LACPTransmitRate=fast
# ext.network [Match] Name=ext [Link] [Network] IPv6AcceptRA=false [Address] Address=192.0.2.196/27 [Route] Gateway=192.0.2.193 [Address] Address=2001:DB8:0:FF01::C4/64 [Route] Gateway=2001:DB8:0:FF01::1 Metric=128
# ext.network.d/ext-a1.conf [Match] Name=ext [Address] Address=192.0.2.217/32 PreferredLifetime=0
# ext.network.d/ext-a2.conf [Match] Name=ext [Address] Address=2001:DB8:0:FF01::D9/128 PreferredLifetime=0
# ext.network.d/has-vlan-int.conf [Match] Name=ext [Network] VLAN=int
# int.netdev [NetDev] Name=int Kind=vlan [VLAN] Id=13
# int.network [Match] Name=int [Link] [Network] IPv6AcceptRA=false [Address] Address=10.0.1.210/24 [Address] Address=2001:DB8:0:100::D2/64
# veth.network [Match] Name=veth* [Link] Unmanaged=yes RequiredForOnline=no
怎麼了?
原來是這樣的:
[Address] Address=192.0.2.217/32 PreferredLifetime=0
指定
PreferredLifetime
IPv4 地址會導致networkd
楔入。