使用 virt-manager 运行虚拟机时,什么会导致网络丢失?

使用 virt-manager 运行虚拟机时,什么会导致网络丢失?

我是新手virt-managerqemu所以libvirt我几乎不知道如何使用它们。我使用virt-manager的 GUI 来让我更轻松地从 VirtualBox(包括 VBoxManage)过渡到 KVM。

到目前为止,我知道如何使用 GUI 来创建我的虚拟机,但有一个巨大的问题:一旦我的虚拟机启动 - 主机和来宾的网络就会失去连接。

无论是 NAT 还是桥接,一旦虚拟机启动 - 主机和来宾都没有网络。只要虚拟机正在运行,我就无法浏览网络来查找解决方案 - 我必须将其关闭,然后恢复网络。

我去journalctl -r(和sudo)看看是什么原因造成的。我不太擅长理解journalctl的输出,所以我在这里分享它,也许有人可以在我的日志中找到问题?

Apr 20 19:01:41 myuser systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
Apr 20 19:01:32 myuser kernel: audit: type=1400 audit(1713628892.242:110): apparmor="STATUS" operation="profile_remove" profile="unconfined" name="libvirt-92b7cf2e-326>
Apr 20 19:01:32 myuser audit[59392]: AVC apparmor="STATUS" operation="profile_remove" profile="unconfined" name="libvirt-92b7cf2e-3262-4f04-ad63-37d5e4d94b70" pid=5939>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {newlink} index 7 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {newlink} index 7 address 52:54:00:6B:A6:9E mtu 1500
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {update} flags 4099 <UP>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {TX} 28 packets 3938 bytes
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {RX} 40 packets 3476 bytes
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {dellink} index 8 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {newlink} index 7 operstate 6 <UP>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {newlink} index 7 address 52:54:00:6B:A6:9E mtu 1500
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {update} flags 4163 <UP,RUNNING>
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {TX} 28 packets 3938 bytes
Apr 20 19:01:32 myuser connmand[1102]: virbr1 {RX} 40 packets 3476 bytes
Apr 20 19:01:32 myuser connmand[1102]: Remove interface (null) [ ethernet ]
Apr 20 19:01:32 myuser connmand[1102]: (null) {remove} index 8
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {dellink} index 8 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 address FE:54:00:DB:3A:50 mtu 1500
Apr 20 19:01:32 myuser connmand[1102]: (null) {del} address 169.254.64.167/16 label vnet2
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 address FE:54:00:DB:3A:50 mtu 1500
Apr 20 19:01:32 myuser connmand[1102]: (null) {del} route fe80:: gw :: scope 0 <UNIVERSE>
Apr 20 19:01:32 myuser connmand[1102]: Removing default interface route failed (No such device)
Apr 20 19:01:32 myuser connmand[1102]: Removing default interface route failed (No such device)
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 operstate 2 <DOWN>
Apr 20 19:01:32 myuser connmand[1102]: vnet2 {newlink} index 8 address FE:54:00:DB:3A:50 mtu 1500
Apr 20 19:01:32 myuser systemd-machined[935]: Machine qemu-3-linux2022 terminated.
Apr 20 19:01:32 myuser systemd[1]: machine-qemu\x2d3\x2dlinux2022.scope: Consumed 22.066s CPU time.
Apr 20 19:01:32 myuser systemd[1]: machine-qemu\x2d3\x2dlinux2022.scope: Deactivated successfully.
Apr 20 19:01:31 myuser systemd[1]: Started NetworkManager-dispatcher.service - Network Manager Script Dispatcher Service.
Apr 20 19:01:31 myuser dbus-daemon[928]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr 20 19:01:31 myuser systemd[1]: Starting NetworkManager-dispatcher.service - Network Manager Script Dispatcher Service...
Apr 20 19:01:31 myuser dbus-daemon[928]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service>
Apr 20 19:01:31 myuser NetworkManager[1101]: <info>  [1713628891.9478] device (vnet2): released from master device virbr1
Apr 20 19:01:31 myuser NetworkManager[1101]: <info>  [1713628891.9474] device (vnet2): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'remo>
Apr 20 19:01:31 myuser avahi-daemon[925]: Withdrawing address record for 169.254.64.167 on vnet2.
Apr 20 19:01:31 myuser avahi-daemon[925]: Withdrawing address record for fe80::fc54:ff:fedb:3a50 on vnet2.
Apr 20 19:01:31 myuser avahi-daemon[925]: Leaving mDNS multicast group on interface vnet2.IPv4 with address ***.***.**.***.
Apr 20 19:01:31 myuser avahi-daemon[925]: Interface vnet2.IPv4 no longer relevant for mDNS.
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {newlink} index 7 operstate 2 <DOWN>
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {newlink} index 7 address 52:54:00:6B:A6:9E mtu 1500
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {update} flags 4099 <UP>
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {dellink} index 8 operstate 2 <DOWN>
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {newlink} index 7 operstate 6 <UP>
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {newlink} index 7 address 52:54:00:6B:A6:9E mtu 1500
Apr 20 19:01:31 myuser connman-vpnd[927]: virbr1 {update} flags 4163 <UP,RUNNING>
Apr 20 19:01:31 myuser kernel: virbr1: port 1(vnet2) entered disabled state
Apr 20 19:01:31 myuser kernel: device vnet2 left promiscuous mode
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {remove} index 8
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {dellink} index 8 operstate 2 <DOWN>
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {newlink} index 8 operstate 2 <DOWN>
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {newlink} index 8 address FE:54:00:DB:3A:50 mtu 1500
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {newlink} index 8 operstate 2 <DOWN>
Apr 20 19:01:31 myuser kernel: virbr1: port 1(vnet2) entered disabled state
Apr 20 19:01:31 myuser connman-vpnd[927]: vnet2 {newlink} index 8 address FE:54:00:DB:3A:50 mtu 1500

我已经启用了libvirtfirewalld区域:hometrusted甚至public。这似乎不起作用。

使用 Debian 12.5 (Bookworm),LXQt 桌面 GUI

更新:当我将虚拟机的网络设置为“隔离”时,我的虚拟机上可能没有任何网络,但我的主机上的网络将工作。它发生在非隔离网络上

更新2:我停止了firewalld,但这没有帮助,所以这不是防火墙问题

请帮我解决这个问题。谢谢


对@AB 的回复 -

更新 - 当虚拟机开启时(主机)*:

$ sudo bash -c "ip link; ip -br addr; ip route; ip rule; ip neigh"
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: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 10:7b:44:93:7e:60 brd ff:ff:ff:ff:ff:ff
3: enx00e04c6802a7: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:e0:4c:68:02:a7 brd ff:ff:ff:ff:ff:ff
5: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:3a:4a:9b brd ff:ff:ff:ff:ff:ff
6: vnet0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc noqueue master virbr0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:54:00:d6:4a:49 brd ff:ff:ff:ff:ff:ff
lo               UNKNOWN        127.0.0.1/8 ::1/128 
enp3s0           UP             192.168.1.9/24 fe80::127b:44ff:fe93:7e60/64 
enx00e04c6802a7  DOWN           
virbr0           UP             192.168.100.1/24 
vnet0            UNKNOWN        169.254.149.177/16 fe80::fc54:ff:fed6:4a49/64 
0.0.0.0 dev vnet0 scope link 
default dev vnet0 scope link 
169.254.0.0/16 dev vnet0 proto kernel scope link src 169.254.149.177 
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.9 
192.168.1.1 dev enp3s0 scope link 
192.168.100.0/24 dev virbr0 proto kernel scope link src 192.168.100.1 
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
192.168.1.6 dev enp3s0 lladdr 00:00:c0:34:14:db STALE 
192.168.100.202 dev virbr0 lladdr 52:54:00:d6:4a:49 STALE 
192.168.1.1 dev enp3s0 lladdr 74:da:88:d6:c8:e6 STALE 
198.252.206.25 dev vnet0 FAILED 
192.168.1.5 dev enp3s0 lladdr 50:eb:f6:24:85:a6 STALE 
fe80::76da:88ff:fed6:c8e6 dev enp3s0 lladdr 74:da:88:d6:c8:e6 router STALE 
fe80::9c7a:f1bb:ca7f:4c1e dev enp3s0 lladdr 50:eb:f6:24:85:a6 STALE 
$ sudo systemctl stop firewalld.service && sudo nft list ruleset
table ip filter {
}
table ip nat {
}
table ip mangle {
}
table ip6 filter {
}
table ip6 nat {
}
table ip6 mangle {
}
$ sudo cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
  • 正如我所说 - 当我在来宾上安装 debian 时,我没有终端(或者我不知道如何访问它),所以我无法提供来宾的信息

答案1

在@AB 的帮助下,我找出了问题所在 - 以及......如何解决它!

connmandAB 给了我关于使用和NM(NetworkManager) 的提示。我开始调查这个问题,我发现它Virt-manager用于NM网络,而我的设备/接口(enp3s0)是通过connmand(LXQt GUI 的一部分)控制的。

所以我做了以下事情:

  1. 我决定使用 NetworkManager 启用我的设备。NM说我的设备“严格不受管理”,所以我决定将我的设备从connman.这很复杂。我find对每个connman可能的目录(在/var/lib和 中/etc)运行了该命令,但没有发现与我的设备相关的任何内容。
  2. 我决定寻找NM的目录 - 也许它在那里配置?当我发现不:
  3. 我决定停止禁用 connmand一阵子。但是,Virt-manager仍然无法使用该设备。
  4. 于是我就走极端了——我已经彻底净化了connman*,永远,并移至NM
  5. 仍然不起作用,但它是永远的 - 因为一旦我从文件中评论了该设备/etc/network/interfacesNM就控制了它(在 的帮助下sudo nmcli device set enp3s0 managed true),我终于让它正常工作了NM
  6. 重新启动(因为我从Windows开始就习惯了,尽管我没有必要),现在我在客户端和主机中都有网络!

相关内容