KVM:Lubuntu 主机,Centos 客户机无互联网访问

KVM:Lubuntu 主机,Centos 客户机无互联网访问

因此,我尝试在 Lubuntu 计算机上的 KVM 虚拟机中练习 Centos。(感觉像个玩笑,但实际上是真的)。​​以下是 Lubuntu 的一些输出,供您阅读:

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::808a:29ff:fe19:6ff5  prefixlen 64  scopeid 0x20<link>
        ether fe:54:00:e4:2e:49  txqueuelen 1000  (Ethernet)
        RX packets 9  bytes 648 (648.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 66  bytes 13239 (13.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s25: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 68:f7:28:3b:e1:eb  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf0600000-f0620000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 313740  bytes 3540721214 (3.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 313740  bytes 3540721214 (3.5 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

macvtap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::5054:ff:feee:e570  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:ee:e5:70  txqueuelen 500  (Ethernet)
        RX packets 148  bytes 22274 (22.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 93  bytes 10767 (10.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 00:00:00:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 13  bytes 1244 (1.2 KB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 51  bytes 4116 (4.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether fe:54:00:e4:2e:49  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 516 (516.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 663 (663.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.101  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 fe80::df85:847:ef0a:abae  prefixlen 64  scopeid 0x20<link>
        ether 5c:c5:d4:4a:97:78  txqueuelen 1000  (Ethernet)
        RX packets 67141  bytes 41980612 (41.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 57144  bytes 10092178 (10.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

bridge name bridge id       STP enabled interfaces
br0     8000.fe5400e42e49   no      vnet0
virbr0      8000.000000000000   yes     

我的 Centos 客户机中有一个 eth0,我认为我需要让它与主机通信。它应该连接到上述众多连接中的哪一个?

更新:

以下是我的 Centos 虚拟机的输出: Centos_ifconfig_输出

答案1

由于您是通过 WiFi 连接的,因此无法桥接连接并让您的 KVM 主机在与您的主机相同的网络上获取 DHCP 地址。看来您的 KVM 已经通过 virbr0 为您的客户机提供 NAT 服务。

你能从 Centos 客户机访问互联网吗?客户机上的 ifconfig 输出是什么?

您应该能够在 192.168.122.X 网络上实现客户机与主机之间的通信,其中主机为 192.168.122.1,而客户机通过 KVM 提供的 DHCP 获取地址。如果确实需要,您可以配置 KVM DHCP 或通过 KVM 手动为客户机设置 IP,但可能不需要。

如果您需要从互联网寻址您的客户机,您不仅需要设置到主机的端口转发,还需要通过 KVM 配置 NAT 端口转发。您可以在此处找到有关此内容的更多信息:https://wiki.libvirt.org/page/Networking#NAT_forwarding_.28aka_.22virtual_networks.22.29 (但如果您确实需要,我建议您只通过以太网插入您的主机并将网络设置更改为桥接模式)

有一些教程教你如何使用 KVM 通过 WiFi 为你的客户端创建桥接连接,但我自己使用与你完全相同的设置(有 4 个 centos 客户端)从未让它正常工作。

相关内容