我在 XEN 虚拟机管理程序上运行两台虚拟机,均搭载 Ubuntu Trusty(Linaro-Developer 版本),并采用以下简单的桥接网络设置:
后端域(dom0):
br0 Link encap:Ethernet HWaddr 02:4d:04:41:96:a9
inet addr:141.79.67.109 Bcast:141.79.71.255 Mask:255.255.248.0
inet6 addr: fe80::4d:4ff:fe41:96a9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4896629 errors:0 dropped:814 overruns:0 frame:0
TX packets:1134 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:356819584 (356.8 MB) TX bytes:277236 (277.2 KB)
eth0 Link encap:Ethernet HWaddr 02:4d:04:41:96:a9
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4906298 errors:0 dropped:0 overruns:0 frame:0
TX packets:2249 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:430584499 (430.5 MB) TX bytes:362740 (362.7 KB)
Interrupt:44
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:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1248 (1.2 KB) TX bytes:1248 (1.2 KB)
vif1.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:1049 errors:0 dropped:0 overruns:0 frame:0
TX packets:4767521 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:66258 (66.2 KB) TX bytes:416912687 (416.9 MB)
来宾域 (domU)
eth0 Link encap:Ethernet HWaddr 00:16:3e:54:95:f5
inet addr:141.79.66.105 Bcast:141.79.71.255 Mask:255.255.248.0
inet6 addr: fe80::216:3eff:fe54:95f5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4879495 errors:0 dropped:815 overruns:0 frame:0
TX packets:1049 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:358293232 (358.2 MB) TX bytes:80944 (80.9 KB)
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:672 (672.0 B) TX bytes:672 (672.0 B)
dom0 中的网络运行良好(apt-get、wget)。但在 domU 中我遇到了一个非常奇怪的问题:ping 运行良好,但 apt-get 和 wget 不起作用。
root@MyUbuntu:~# wget -p http://google.com
--1970-01-01 00:52:49-- http://google.com/
Resolving google.com (google.com)... 129.143.66.27, 129.143.66.29, 129.143.66.30, ...
Connecting to google.com (google.com)|129.143.66.27|:80... connected.
HTTP request sent, awaiting response... No data received.
我在 dom0 上安装了 tcpdump 来调试该问题,并运行了一个简单的命令:
tcpdump -i br0 -n "tcp and src 141.79.66.105"
但是,每当 tcpdump 正在监听时,wget 和 apt-get 都可以正常工作:
root@MyUbuntu:~# wget -p http://google.com
--1970-01-01 00:42:27-- http://google.com/
Resolving google.com (google.com)... 129.143.66.45, 129.143.66.49, 129.143.66.53, ...
Connecting to google.com (google.com)|129.143.66.45|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.google.de/?gfe_rd=cr&ei=qJIzVs3qJqSh8wfLma_QCw [following]
--1970-01-01 00:42:27-- http://www.google.de/?gfe_rd=cr&ei=qJIzVs3qJqSh8wfLma_QCw
Resolving www.google.de (www.google.de)... 129.143.66.38, 129.143.66.42, 129.143.66.44, ...
Reusing existing connection to google.com:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'google.com/index.html'
[ <=> ] 19,468 --.-K/s in 0.003s
1970-01-01 00:42:27 (5.84 MB/s) - 'google.com/index.html' saved [19468]
FINISHED --1970-01-01 00:42:27--
Total wall clock time: 0.09s
Downloaded: 1 files, 19K in 0.003s (5.84 MB/s)
tcpdump 是否打开任何允许流量通过的端口?任何帮助都将不胜感激。谢谢。
答案1
当您启动 tcpdump 时,它会将接口置于混杂模式。这可能是 tcpdump 处于活动状态时允许数据到达 domU 的原因。
您可以通过添加--no-promiscuous-mode
tcpdump 命令来测试该理论。或者手动将接口设置为混杂模式。
但不确定这如何有助于解决实际问题。
答案2
桥接时,物理接口必须处于混杂模式。这样才能看到并转发发往桥接器和虚拟接口的数据包。
解决方案是确保您的eth0
配置启用了“promisc”。