我尝试遵循以下手动示例man systemd.network
:
# /etc/systemd/network/27-xfrm.netdev
[NetDev]
Name=xfrm0
Kind=xfrm
[Xfrm]
InterfaceId=7
# /etc/systemd/network/27-eth0.network
[Match]
Name=ens5
[Network]
Xfrm=xfrm0
然后systemctl daemon-reload
+ systemctl restart systemd-networkd
。没事了。其中systemctl status systemd-networkd
也没有显示任何对以下内容的引用xfrm
:
Apr 16 23:52:07 ip-10-100-1-205 systemd[1]: Starting Network Configuration...
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: ens5: Link UP
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: ens5: Gained carrier
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: lo: Link UP
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: lo: Gained carrier
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: ens5: Gained IPv6LL
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: Enumeration completed
Apr 16 23:52:07 ip-10-100-1-205 systemd[1]: Started Network Configuration.
Apr 16 23:52:07 ip-10-100-1-205 systemd-networkd[960]: ens5: DHCPv4 address 10.100.1.205/24 via 10.100.1.1
它是 aws 上的 ubuntu 22.04,带有 systemd v249。
我还尝试添加另一个.network
模块:
[Match]
Name=xfrm*
[Link]
ActivationPolicy=up
RequiredForOnline=no
没有成功。
我缺少什么?
更新:
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
link/ether 06:ea:6f:cf:a8:51 brd ff:ff:ff:ff:ff:ff
inet 10.100.1.205/24 metric 100 brd 10.100.1.255 scope global dynamic ens5
valid_lft 2529sec preferred_lft 2529sec
inet6 fe80::4ea:6fff:fecf:a851/64 scope link
valid_lft forever preferred_lft forever
(我手动添加了xfrm接口,因此ens5
MTU已降至1500,否则它是同一台机器)
# networkctl status ens5
● 2: ens5
Link File: /usr/lib/systemd/network/99-default.link
Network File: /run/systemd/network/10-netplan-ens5.network
Type: ether
State: routable (configured)
Online state: online
Alternative Names: enp0s5
Path: pci-0000:00:05.0
Driver: ena
Vendor: Amazon.com, Inc.
Model: Elastic Network Adapter (ENA)
HW Address: 06:ea:6f:cf:a8:51
MTU: 1500 (min: 128, max: 9216)
QDisc: mq
IPv6 Address Generation Mode: eui64
Queue Length (Tx/Rx): 2/2
Address: 10.100.1.100
10.100.1.205
fe80::4ea:6fff:fecf:a851
Gateway: 10.100.1.1
Activation Policy: up
Required For Online: yes
DHCP6 Client DUID: DUID-EN/Vendor:0000ab11874fdc08796f22200000
Apr 17 02:55:13 ip-10-100-1-205 systemd-networkd[322]: ens5: Link UP
Apr 17 02:55:13 ip-10-100-1-205 systemd-networkd[322]: ens5: Gained carrier
Apr 17 02:55:13 ip-10-100-1-205 systemd-networkd[322]: ens5: Link DOWN
Apr 17 02:55:13 ip-10-100-1-205 systemd-networkd[322]: ens5: Lost carrier
Apr 17 02:55:13 ip-10-100-1-205 systemd-networkd[322]: ens5: Link UP
Apr 17 02:55:14 ip-10-100-1-205 systemd-networkd[322]: ens5: Gained carrier
Apr 17 02:55:15 ip-10-100-1-205 systemd-networkd[322]: ens5: Gained IPv6LL