我正试图在Ubuntu20.04.3上设置一个nspawe-容器。主机网络配置包含一个桥接口:
br0: flags=4163 mtu 1500
inet * netmask 255.255.255.255 broadcast 0.0.0.0
inet6 * prefixlen 64 scopeid 0x0
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 mtu 1500
inet6 fe80::c8fc:b8ff:fed1:176 prefixlen 64 scopeid 0x20
ether ca:fc:b8:d1:01:76 txqueuelen 1000 (Ethernet)容器中有一个接口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 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
ether f6:d9:2b:ba:7a:1d txqueuelen 1000 (Ethernet)
...不幸的是,networkd似乎没有找到接口host0。没有分配地址,也没有分配ip4或ip6。当我将[Match]部分中的D11参数更改为*时,地址将分配给lo接口。
我做错了什么?
发布于 2022-01-22 21:37:56
Systemd已经提供了一个与host0接口匹配的networkd配置:
/usr/lib/systemd/network/80-container-host0.networkNetworkd按顺序读取所有.network文件,第一个匹配文件获胜。(在ASCII中,顺序大致为0-9 A-Z a-z。)要使您的自定义配置具有优先级,必须在80-container-host0 (如50-custom-host0 )之前对其文件名进行排序。
(只有当两个文件的名称相同时,目录才重要--在这种情况下,/etc中的文件比/usr/lib中的同名文件具有优先级。)
https://unix.stackexchange.com/questions/687488
复制相似问题