我有 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 操作正常。
- domU 和 PC2 之间的 Ping 通畅。
- 从 domU 到 dom0(PC1)的 Ping 不正常!
感谢您的时间和帮助!
答案1
eth0 和 xenbr0 都有一个 IP(甚至是同一个 IP)。删除 eth0 上的 IP。网桥是第 2 层抽象,因此您不能在连接到它的接口上进行第 3 层寻址。将 IP 保留在网桥接口上,因为那是您将第 3 层寻址放在的接口上。对于您连接到网桥的任何设备(包括绑定),这都是正确的。第 2 层堆栈的末端获取第 3 层地址。