当尝试通过 NAT 从主机操作系统访问客户操作系统时,大约 50% 的 HTTP 请求被拒绝/超时。通过以下方式调用的请求http://本地主机:8001
以下是一些详细信息:
Host OS: Mac OS X Lion (10.7.2) - 64 bit
Guest OS: CentOS 5.7 2.6.18-274.el5 - 64 Bit
VirtualBox: 4.1.6.r74713 - Network Adapter Type: NAT
端口转发已设置并正在运行:
$ VBoxManage showvminfo thevm |grep "NIC 1"
NIC 1: MAC: 0800272C2273, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 1 Settings: MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0): name = http, protocol = tcp, host ip = , host port = 8001, guest ip = , guest port = 80
NIC 1 Rule(3): name = ssh, protocol = tcp, host ip = , host port = 2222, guest ip = , guest port = 22
从主机操作系统:
$ netstat -nl |grep tcp |grep 127.0.0.1
tcp4 0 0 127.0.0.1.8001 127.0.0.1.59056 ESTABLISHED
tcp4 0 0 127.0.0.1.8001 127.0.0.1.59055 ESTABLISHED
tcp4 0 0 127.0.0.1.59056 127.0.0.1.8001 ESTABLISHED
tcp4 0 0 127.0.0.1.8001 127.0.0.1.59054 ESTABLISHED
tcp4 0 0 127.0.0.1.59055 127.0.0.1.8001 ESTABLISHED
tcp4 0 0 127.0.0.1.59054 127.0.0.1.8001 ESTABLISHED
tcp4 0 0 127.0.0.1.2222 127.0.0.1.58891 ESTABLISHED
tcp4 0 0 127.0.0.1.58891 127.0.0.1.2222 ESTABLISHED
tcp4 0 0 127.0.0.1.5037 127.0.0.1.54240 ESTABLISHED
tcp4 0 0 127.0.0.1.54240 127.0.0.1.5037 ESTABLISHED
同样来自主机操作系统:
$ netstat -nl |grep tcp |grep 127.0.0.1
tcp4 0 0 127.0.0.1.56778 127.0.0.2.80 SYN_SENT
tcp4 0 0 127.0.0.1.56777 127.0.0.2.80 SYN_SENT
tcp4 0 0 127.0.0.1.56776 127.0.0.2.80 SYN_SENT
tcp4 0 0 127.0.0.1.2222 127.0.0.1.55086 ESTABLISHED
tcp4 0 0 127.0.0.1.55086 127.0.0.1.2222 ESTABLISHED
tcp4 0 0 127.0.0.1.2222 127.0.0.1.54727 ESTABLISHED
tcp4 0 0 127.0.0.1.54727 127.0.0.1.2222 ESTABLISHED
tcp4 0 0 127.0.0.1.5037 127.0.0.1.54240 ESTABLISHED
tcp4 0 0 127.0.0.1.54240 127.0.0.1.5037 ESTABLISHED
(127.0.0.2 的目的地对我来说看起来有点偏离……)
从客户操作系统:
$ netstat -nl |grep tcp
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:670 0.0.0.0:* LISTEN
SSH 运行良好 - 完全没有问题。
我的 google-fu 在这方面让我很失望。此 VM 最初是在 Win7 机器上创建的,然后导出,然后导入到 OS X Lion。它在 Win7 上运行良好(对于使用 Windows 机器的开发人员来说,它仍然如此)。
iptables 已被禁用 - 以及 SELinux。
以下是来自客户操作系统的 tcpdump:
$tcpdump -v |grep http
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
15:19:39.304055 IP (tos 0x0, ttl 64, id 47318, offset 0, flags [none], proto: TCP (6), length: 44) 10.0.2.2.58975 > 10.0.2.15.http: S, cksum 0x0bf8 (correct), 225280001:225280001(0) win 65535 <mss 1460>
15:19:39.304081 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: TCP (6), length: 44) 10.0.2.15.http > 10.0.2.2.58975: S, cksum 0xa1a1 (correct), 1043076425:1043076425(0) ack 225280002 win 5840 <mss 1460>
15:19:39.304120 IP (tos 0x0, ttl 64, id 47319, offset 0, flags [none], proto: TCP (6), length: 44) 10.0.2.2.58976 > 10.0.2.15.http: S, cksum 0x11f6 (correct), 225344001:225344001(0) win 65535 <mss 1460>
15:19:39.304126 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: TCP (6), length: 44) 10.0.2.15.http > 10.0.2.2.58976: S, cksum 0xb6b7 (correct), 1039140461:1039140461(0) ack 225344002 win 5840 <mss 1460>
15:19:39.304154 IP (tos 0x0, ttl 64, id 47320, offset 0, flags [none], proto: TCP (6), length: 40) 10.0.2.2.58975 > 10.0.2.15.http: ., cksum 0xd02e (correct), ack 1 win 65535
15:19:39.304258 IP (tos 0x0, ttl 64, id 47321, offset 0, flags [none], proto: TCP (6), length: 44) 10.0.2.2.58978 > 10.0.2.15.http: S, cksum 0x17f3 (correct), 225408001:225408001(0) win 65535 <mss 1460>
15:19:39.304264 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: TCP (6), length: 44) 10.0.2.15.http > 10.0.2.2.58978: S, cksum 0x1ffb (correct), 1041146632:1041146632(0) ack 225408002 win 5840 <mss 1460>
15:19:39.304291 IP (tos 0x0, ttl 64, id 47322, offset 0, flags [none], proto: TCP (6), length: 40) 10.0.2.2.58976 > 10.0.2.15.http: ., cksum 0xe544 (correct), ack 1 win 65535
15:19:39.304294 IP (tos 0x0, ttl 64, id 47323, offset 0, flags [none], proto: TCP (6), length: 44) 10.0.2.2.58979 > 10.0.2.15.http: S, cksum 0x1df1 (correct), 225472001:225472001(0) win 65535 <mss 1460>
任何帮助是极大的赞赏。
答案1
freenode 上的 #vbox IRC 频道中的一位用户向我指出:Virtualbox 错误报告。问题就解决了。解决方案如下:
根据您的客户虚拟机的配置,执行以下命令之一:
# VBoxManage set extradata <vmname> \ "VBoxInternal/Devices/e1000/0/LUN#0/Config/SoMaxConnection" 10
或者
# VBoxManage set extradata <vmname> \ "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SoMaxConnection" 10