重要更新:

重要更新:

在 virt-manager 中使用所有默认设置和网络类型 NAT 创建的 Ubuntu QEMU/KVM 来宾无法激活其网络。我的主机是 Fedora 35。下面是访客的 NetworkManager 日志的屏幕截图。

来宾 VM 网络管理器日志

以下是设备设置中 virt-manager 的 NIC 选项卡中的 XML 配置:

<interface type="network">
  <mac address="redacted but present"/>
  <source network="default" portid="redacted but present" bridge="virbr0"/>
  <target dev="vnet2"/>
  <model type="virtio"/>
  <alias name="net0"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

以及 virt-manager 的虚拟网络 XML:

<network connections="2">
  <name>default</name>
  <uuid>redacted but present</uuid>
  <forward mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="redacted but present"/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254"/>
    </dhcp>
  </ip>
</network>

virsh 网络列表 --全部

 Name      State    Autostart   Persistent
--------------------------------------------
 default   active   yes         yes

brctl显示

bridge name bridge id       STP enabled interfaces
virbr0      redacted    yes     

ip -br 链接显示

lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
enp34s0          UP             redacted <BROADCAST,MULTICAST,UP,LOWER_UP>
virbr0           DOWN           redacted <NO-CARRIER,BROADCAST,MULTICAST,UP>
wg-mullvad       UNKNOWN        <POINTOPOINT,UP,LOWER_UP>

nmcli 连接显示 --active

NAME                UUID                                  TYPE       DEVICE
Wired connection 1  redacted  ethernet   enp34s0
virbr0              redacted  bridge     virbr0
wg-mullvad          redacted  wireguard  wg-mullvad

systemctl 状态 libvirtd

○ libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled; vendor preset: disabled)
     Active: inactive (dead) since Mon 2022-04-04 05:13:01; 1min 40s ago
TriggeredBy: ○ libvirtd-tls.socket
             ● libvirtd-admin.socket
             ○ libvirtd-tcp.socket
             ● libvirtd.socket
             ● libvirtd-ro.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
    Process: 36276 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 36276 (code=exited, status=0/SUCCESS)
        CPU: 439ms

Apr 04 05:12:49 host systemd[1]: Starting Virtualization daemon...
Apr 04 05:12:49 host systemd[1]: Started Virtualization daemon.
Apr 04 05:13:01 host systemd[1]: Stopping Virtualization daemon...
Apr 04 05:13:01 host systemd[1]: libvirtd.service: Deactivated successfully.
Apr 04 05:13:01 host systemd[1]: Stopped Virtualization daemon.
[user@host ~]$ sudo systemctl status libvirtd
○ libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled; vendor preset: disabled)
     Active: inactive (dead) since Mon 2022-04-04 05:13:01; 2min 1s ago
TriggeredBy: ○ libvirtd-tls.socket
             ● libvirtd-admin.socket
             ○ libvirtd-tcp.socket
             ● libvirtd.socket
             ● libvirtd-ro.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
    Process: 36276 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 36276 (code=exited, status=0/SUCCESS)
        CPU: 439ms

Apr 04 05:12:49 host systemd[1]: Starting Virtualization daemon...
Apr 04 05:12:49 host systemd[1]: Started Virtualization daemon.
Apr 04 05:13:01 host systemd[1]: Stopping Virtualization daemon...
Apr 04 05:13:01 host systemd[1]: libvirtd.service: Deactivated successfully.
Apr 04 05:13:01 host systemd[1]: Stopped Virtualization daemon

systemctl --失败

  UNIT                  LOAD   ACTIVE SUB    DESCRIPTION
● nvidia-powerd.service loaded failed failed nvidia-powerd service

到目前为止我尝试过的事情:

  • 检查我是否安装了以下软件包: qemu dhclient netcat virt-viewer libvirt dnsmasq dmidecode ebtables virt-install virt-managerbridge-utils
  • 检查网络“默认”是否在 virsh 中启动
  • 确保firewalld已安装并正在运行
  • 使用firewall-cmd get-active-zones 检查 virbr0 是否位于 libvirt 区域中

重要更新:

进一步的故障排除表明我正在使用的 VPN 导致了此问题。在禁用 VPN 的情况下启动虚拟机可以让它们连接到网络和互联网。我的 VPN 应用程序称为 Mulvad,并使用 Wireguard 协议。我怎样才能做到这一点,以便虚拟机通过 VPN 连接到互联网?

答案1

问题在于使用 VPN 时未启用“允许本地网络共享”设置。启用它就可以了。

答案2

启用转发

sysctl net.ipv4.ip_forward=1

可能有帮助。

相关内容