我正在尝试在 Ubuntu 20.04.3 上设置一个 nspawn-container。主机网络配置包含一个桥接接口:
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet * netmask 255.255.255.255 broadcast 0.0.0.0
inet6 * prefixlen 64 scopeid 0x0<global>
ether 41:8a:5b:d8:83:00 txqueuelen 1000 (Ethernet)
RX packets 5914822 bytes 888728796 (888.7 MB)
RX errors 0 dropped 449 overruns 0 frame 0
TX packets 30323548 bytes 37836188291 (37.8 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
容器开始于:
systemd-nspawn -UbM helloworld --network-bridge=br0
容器启动时,vb-helloworld
创建接口:
vb-helloworld: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::c8fc:b8ff:fed1:176 prefixlen 64 scopeid 0x20<link>
ether ca:fc:b8:d1:01:76 txqueuelen 1000 (Ethernet)
在容器中,有一个 interface host0
,应该由systemd-networkd
config处理/etc/systemd/network/host0.network
:
[Match]
Name=host0
[Network]
DHCP=false
Address=*:*:*:*::100/64
Gateway=fe80::1
DNS=2a01:4ff:*::*:1
Address=192.168.50.10/24
Gateway=192.168.50.1
DNS=192.168.50.2
ConfigureWithoutCarrier=yes
[Link]
MACAddress=f6:d9:2b:ba:7a:1d
ARP=true
RequiredForOnline=yes
[Address]
Address=*:*:*:*::100/64
Scope=global
[Route]
Gateway=fe80::1
Scope=global
容器有接口:
host0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.214.0 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::f4d9:2bff:feba:7a1d prefixlen 64 scopeid 0x20<link>
ether f6:d9:2b:ba:7a:1d txqueuelen 1000 (Ethernet)
...
不幸的是,networkd 似乎没有找到 interface host0
。没有分配地址,既不是 ip4 也不是 ip6。当我将Name
部分中的参数更改[Match]
为 时*
,地址将分配给lo
接口。
我究竟做错了什么?