桥接网络停止与 kvm/qemu 一起工作

桥接网络停止与 kvm/qemu 一起工作

2-3个月前我关注了这篇文章https://brooks.sh/2017/12/22/configuring-kvm-on-clear-linux/为 kvm/qemu guest ubuntu 设置桥接网络。我的主机操作系统是 ClearLinux。然而,客户操作系统网络在 1 周前停止工作,无法从 dhcp 获取 IP 地址。我不记得除了关注 ClearLinux 更新之外我还做过什么特别的事情。

我的情况和这个很相似使用 systemd-networkd 配置桥接接口但那里的解决方案不适合我。

我的配置

/etc/systemd/network/br0.netdev

[NetDev]
Name=br0
Kind=bridge

/etc/systemd/network/br0.network

[Match]
Name=br0

[Network]
DHCP=yes

/etc/systemd/network/80-dhcp.network

[Match]
Name=enp12s0

[Network]
Bridge=br0

/etc/sysctl.d/90-bridge.conf

net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0

$ brctl 显示

bridge name bridge id       STP enabled interfaces
br0     8000.fedc02dff363   no      enp12s0

网络控制

IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     unmanaged 
  2 enp12s0          ether              degraded    configured
  3 br0              bridge             routable    configured

3 links listed.

$ systemctl 状态 systemd-networkd

● systemd-networkd.service - Network Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-01-27 17:30:17 AEDT; 19min ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 504 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   Memory: 976.0K
   CGroup: /system.slice/systemd-networkd.service
           └─504 /usr/lib/systemd/systemd-networkd

Jan 27 17:30:18 clr systemd-networkd[504]: enp12s0: Gained carrier
Jan 27 17:30:18 clr systemd-networkd[504]: enp12s0: Configured
Jan 27 17:30:18 clr systemd-networkd[504]: br0: Gained carrier
Jan 27 17:30:19 clr systemd-networkd[504]: enp12s0: Gained IPv6LL
Jan 27 17:30:20 clr systemd-networkd[504]: br0: Gained IPv6LL
Jan 27 17:30:21 clr systemd-networkd[504]: br0: DHCPv4 address 192.168.2.107/24 via 192.168.2.1
Jan 27 17:30:32 clr systemd-networkd[504]: br0: Configured
Jan 27 17:31:06 clr systemd-networkd[504]: vnet0: Gained carrier
Jan 27 17:31:07 clr systemd-networkd[504]: vnet0: Gained IPv6LL
Jan 27 17:32:17 clr systemd-networkd[504]: vnet0: Lost carrier

在我的 vm.xml 中,网络接口部分是

<interface type='bridge'>
  <mac address='00:16:3e:11:22:33'/>
  <source bridge='br0'/>
  <model type='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

在主机 ip 链接显示上,结果是

$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp12s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 40:8d:5c:11:22:33 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether fe:dc:02:df:f3:63 brd ff:ff:ff:ff:ff:ff
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq master br0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:16:3e:04:22:5b brd ff:ff:ff:ff:ff:ff

在来宾操作系统中,以太网接口为 en3,链路状态也是“BROADCAST,MULTICAST,UP,LOWER_UP”。

答案1

又过了一周,问题就消失了。我应该得出结论,这是过去三周内引入的 ClearLinux 中的一个动态错误。

相关内容