我有 2 台本地连接的 PC。我在 PC1 上创建了 2 个虚拟机,并使用 dom0 中的 eth0 接口通过桥接添加了连接。
From dom0:
#brctl addbr xenbr0
#brctl addif xenbr0 eth0
#ifconfig xenbr0 10.0.2.4
#xl create /etc/xen/dom1.cfg
#xl create /etc/xen/dom2.cfg
#ifconfig
eth0 Link encap:Ethernet HWaddr 00:0A:35:00:22:01
inet addr:10.0.2.1 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20a:35ff:fe00:2201/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:228 errors:0 dropped:0 overruns:0 frame:0
TX packets:1228 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36193 (35.3 KiB) TX bytes:407300 (397.7 KiB)
Interrupt:25
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)
vif2.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:2524 (2.4 KiB) TX bytes:2558 (2.4 KiB)
vif3.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:1212 (1.1 KiB) TX bytes:1165 (1.1 KiB)
xenbr0 Link encap:Ethernet HWaddr 00:0A:35:00:22:01
inet addr:10.0.2.3 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20a:35ff:fe00:2201/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4224 (4.1 KiB) TX bytes:648 (648.0 B)
在 Xen cfg 文件中,我有这一行“vif = ['script=vif-bridge, bridge=xenbr0']”
来自 domU
#ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:60:FC:91
inet addr:10.0.2.6 Bcast:10.255.255.255 Mask:255.0.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:94 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23886 (23.3 KiB) TX bytes:22500 (21.9 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
引导到访客虚拟机后,我有以下 ping 状态:
- domU 之间 ping 正常。
- domUs 和 PC2 之间 Ping 正常。
- 从 domU ping 到 dom0(PC1) 不正常!
感谢您的时间和帮助!
eth0 和 xenbr0 都有一个 IP(甚至是同一个 IP)。去掉 eth0 上的 IP。网桥是第 2 层抽象,因此您不能在连接到它的接口上使用第 3 层寻址。将 IP 保留在网桥接口上,因为那是您放置第 3 层寻址的那个。任何连接到桥梁的东西都是如此,包括债券。第 2 层堆栈的末尾获得第 3 层地址。