这个问题困扰了我好几天。我在 PowerKVM 主机上运行 Ubuntu 14.04 客户机(PowerKVM 是 IBM Power Systems 上的 KVM,所以基本上就是 KVM。)。我无法让桥接网络工作。我甚至无法 ping 默认网关。我猜是 XML 配置文件出了问题。
这些是文件。
KVM 主机
localhost:/root # ifconfig -a
brenP3p5s0f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.229.200 netmask 255.255.255.192 broadcast 172.16.229.255
inet6 fe80::42f2:e9ff:fe5d:61bb prefixlen 64 scopeid 0x20<link>
ether 40:f2:e9:5d:61:bb txqueuelen 0 (Ethernet)
RX packets 40709 bytes 3013319 (2.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 6015 (5.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enP3p5s0f0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 40:f2:e9:5d:61:b8 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 252
enP3p5s0f1: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 40:f2:e9:5d:61:b9 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 253
enP3p5s0f2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.229.199 netmask 255.255.255.192 broadcast 172.16.229.255
inet6 fe80::42f2:e9ff:fe5d:61ba prefixlen 64 scopeid 0x20<link>
ether 40:f2:e9:5d:61:ba txqueuelen 1000 (Ethernet)
RX packets 36345 bytes 4200608 (4.0 MiB)
RX errors 0 dropped 2 overruns 0 frame 0
TX packets 23689 bytes 12817261 (12.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 252
enP3p5s0f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::42f2:e9ff:fe5d:61bb prefixlen 64 scopeid 0x20<link>
ether 40:f2:e9:5d:61:bb txqueuelen 1000 (Ethernet)
RX packets 32473 bytes 2927091 (2.7 MiB)
RX errors 0 dropped 3080 overruns 0 frame 0
TX packets 364 bytes 78478 (76.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 253
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 0 (Local Loopback)
RX packets 108802 bytes 28022560 (26.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 108802 bytes 28022560 (26.7 MiB)
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 52:54:00:7b:a3:23 txqueuelen 0 (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
virbr1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.121.1 netmask 255.255.255.0 broadcast 192.168.121.255
ether 52:54:00:1e:11:18 txqueuelen 0 (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
virbr0-nic: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 52:54:00:7b:a3:23 txqueuelen 500 (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
virbr1-nic: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 52:54:00:1e:11:18 txqueuelen 500 (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
主机的路由表
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.229.193 0.0.0.0 UG 0 0 0 enP3p5s0f2
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 enP3p5s0f2
169.254.0.0 0.0.0.0 255.255.0.0 U 1039 0 0 brenP3p5s0f3
172.16.229.192 0.0.0.0 255.255.255.192 U 0 0 0 enP3p5s0f2
172.16.229.192 0.0.0.0 255.255.255.192 U 0 0 0 brenP3p5s0f3
192.168.121.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr1
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
保存在主机中的客户机 XML 文件(界面部分)。
localhost:/root # virsh edit ubuntu01
<interface type='bridge'>
<mac address='52:54:00:b8:bd:eb'/>
<source bridge='brenP3p5s0f3'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
主机中保存的桥接网络 XML 文件:
localhost:/root # cat /etc/libvirt/qemu/networks/bridged.xml
<network>
<name>bridged</name>
<uuid>01ebaa45-0034-4a3f-8d57-fe67e03130b6</uuid>
<forward mode='bridge'/>
<bridge name='brenP3p5s0f3'/>
</network>
客人
我无法复制/粘贴,因为我无法使用 ssh(因为它无法访问),而且 virsh 上的控制台不知何故不起作用。但是,当我启动虚拟机时,我看不到定义的 ip 地址。然后我做了以下事情:
ifconfig eth0 172.16.229.201 netmask 255.255.255.192 up
ip route add default via 172.16.229.193
主机的默认网关也相同。我使用的网络掩码对于客户机和主机都相同。
问题:当我 ping 默认网关时,出现错误“目标主机无法访问”。当我 ping 自己 172.16.229.201 时,可以成功 ping。
一个更新:尝试 tcpdump 默认网关的 IP 地址时发生了一个有趣的行为:我得到了类似这样的信息:
ARP, Request who-has 10.10.10.6 tell 10.10.10.105, length 46
ARP, Request who-has 10.10.10.6 tell 10.10.10.102, length 46
ARP, Request who-has 10.10.10.252 tell 10.10.10.253, length 46
IP 10.10.10.2.1985 > 224.0.0.102.1985: HSRPv1
像这样的多行。我不知道它从哪里获取这些 IP 地址。“有趣”的是,我通过 tcpdump 主机上的桥接接口获得了相同的输出!因此,看起来 tcpdump 正在以某种方式从客户机访问网络!否则我无法解释为什么这些行是相同的。我想强调的是,这些以 10 开头的私有 IP 地址未在我的子网中的任何地方分配。
任何想法?
提前致谢!