![KVM 桥接接口无法启动 - inet、inet6、bridge](https://linux22.com/image/84987/KVM%20%E6%A1%A5%E6%8E%A5%E6%8E%A5%E5%8F%A3%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%20-%20inet%E3%80%81inet6%E3%80%81bridge.png)
我正在设置 KVM 主机,该主机将具有多个从外部可见的虚拟机,其/etc/network/interfaces
配置与此 类似
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
iface eth0 inet6 static
address 2001:0000:1004:1019::
netmask 64
post-up /sbin/ip -family inet6 route add 2001:0000:1004:10ff:ff:ff:ff:ff dev eth0
post-up /sbin/ip -family inet6 route add default via 2001:0000:1004:10ff:ff:ff:ff:ff
pre-down /sbin/ip -family inet6 route del default via 2001:0000:1004:10ff:ff:ff:ff:ff
pre-down /sbin/ip -family inet6 route del 2001:0000:1004:10ff:ff:ff:ff:ff dev eth0
auto br0
iface br0 inet static
address 41.100.60.25
netmask 255.255.255.0
network 41.100.60.0
broadcast 41.100.60.255
gateway 41.100.60.254
bridge_ports eth0
bridge_maxwait 12
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
dns-nameservers 8.8.8.8
dns-search ovh.net
post-up ip link set br0 address xx:xx:xx:xx:xx:xx
post-up ip addr add 164.123.123.123/32 dev br0 broadcast 164.123.123.123
post-down ip addr del 164.123.123.123/32 dev br0
post-up ip route add default via 41.100.60.254 dev br0
post-down ip route del default via 41.100.60.254 dev br0
post-down brctl delbr br0
eth0 和 br0 接口最终都会启动(它们可以工作),但是当我查看启动屏幕时我看到了这一点(由于某种原因它不在启动日志中):
Waiting for network configuration
Waiting upto 60 more seconds for network configuration"
Booting system without full network configuration
另外当我跑步时
ifquery --state
或者
cat /run/network/ifstate
我可以看到 eth0 和 br0 丢失了
lo=lo
编辑1:
通过使用以下命令
ifup br0 --no-act
如果您使用的话,我得到了正在运行的以下命令集ifup br0
run-parts /etc/network/if-pre-up.d
ip addr add 41.100.60.25/255.255.255.0 broadcast 41.100.60.255 dev br0 label br0
ip link set dev br0 up
ip route add default via 41.100.60.254 dev br0
ip link set br0 address xx:xx:xx:xx:xx:xx
ip addr add 164.123.123.123/32 dev br0 broadcast 164.123.123.123
ip route add default via 41.100.60.254 dev br0
run-parts /etc/network/if-up.d
这告诉我这个命令被重复了
ip route add default via 41.100.60.254 dev br0
所以从我的配置中删除它之后
post-up ip route add default via 41.100.60.254 dev br0
post-down ip route del default via 41.100.60.254 dev br0
我可以看到
run-parts /etc/network/if-pre-up.d
ip addr add 41.100.60.25/255.255.255.0 broadcast 41.100.60.255 dev br0 label br0
ip link set dev br0 up
ip route add default via 41.100.60.254 dev br0
ip link set br0 address xx:xx:xx:xx:xx:xx
ip addr add 164.123.123.123/32 dev br0 broadcast 164.123.123.123
run-parts /etc/network/if-up.d
这解决了我运行时重新启动后丢失 br0 的问题
ifquery --state
# or
cat /run/network/ifstate
因为我可以看到
lo=lo
br0=br0
答案1
我决定暂时删除 inet6 静态配置,这样我在“EDIT 1”之后就很好了。
我认为 inet 和 inet6 的配置有两种不同的类型,例如“静态”和“手动”,在运行 ifup 和 ifdown 时会导致一些命令重复。