我遇到了VirtualBox的一个非常奇怪的问题。
大多数时候,我的笔记本电脑都硬连接到以太网连接。有时候,当我不在办公桌旁时,除了Wi-Fi之外,我别无选择。连接到Wi-Fi时,我的主机(Windows 10)可以在几秒钟内访问网络,而没有任何问题。但是,来宾(Windows XP SP3)将像仍处于脱机状态一样工作。
我在VirtualBox中的网络配置为NAT
。
奇怪的是,这仅发生在无线网络上。每当我对计算机进行硬连线时,主机操作系统在获得网络连接时就不会有任何问题。我将其设置为NAT是因为我需要来宾OS可以访问Internet,但是我不希望主机之外的客户端连接到它。我也不想将访客计算机绑定到有线网卡或无线网卡,因为那样一来它只能在一个或另一个上工作。
另一方面,无论何时我连接到Wi-Fi,从访客获得Internet连接总是会出现问题。
有一次我遇到问题,我打了个打字ipconfig /flushdns
,突然事情开始了。从那以后,还远远不够。刷新DNS不足以使事情在Wi-Fi上正常工作。
我发现强迫它工作的唯一方法是进入guest虚拟机的VirtualBox设置,然后将Network adapter从更改NAT
为Bridged
。在这一点上,它仍然无法正常工作。但是,现在,如果我ipconfig /flushdns
在来宾上键入内容,一切都会突然起作用:我可以访问网络。更奇怪的是,我现在可以将其更改回NAT
。突然,它将停止工作,但是,如果我再做ipconfig /flushdns
一次,它将工作。
换句话说,我已经走了整整一圈,回到了NAT
最终可行的连接。起始状态和结束状态完全相同,因此我感到困惑,为什么来宾无法自行获得网络连接。如果ipconfig /flushdns
只要在连接Wi-Fi时只需要键入,那将是一回事,但是必须退出来宾并将适配器从更改NAT
为Bridged
,然后再更改为NAT
,然后键入命令,这确实是一个痛苦。
为什么会发生这种情况,更重要的是,我如何解决此问题,使其与硬连线时一样无缝地工作?(ipconfig /flushdns
例如,当我从Wi-Fi返回以太网时,不需要输入任何内容,也不需要弄乱任何适配器设置)。
这是最近的故障排除会话的命令提示符输出:
刚刚连接到Wi-Fi,无法访问网络:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\InterLinked>ping google.com
Ping request could not find host google.com. Please check the name and try again
.
C:\Documents and Settings\InterLinked>ping google.com
^C
C:\Documents and Settings\InterLinked>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
C:\Documents and Settings\InterLinked>ping google.com
Ping request could not find host google.com. Please check the name and try again
.
更改NAT
为,Bridged
然后重试:
C:\Documents and Settings\InterLinked>
C:\Documents and Settings\InterLinked>ping google.com
我提早终止了它,因此缺少输出,但是ping失败,直到刷新DNS:
^C
C:\Documents and Settings\InterLinked>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
C:\Documents and Settings\InterLinked>ping google.com
Pinging google.com [172.217.7.14] with 32 bytes of data:
Reply from 172.217.7.14: bytes=32 time=15ms TTL=48
Reply from 172.217.7.14: bytes=32 time=13ms TTL=48
Reply from 172.217.7.14: bytes=32 time=15ms TTL=48
Reply from 172.217.7.14: bytes=32 time=20ms TTL=48
Ping statistics for 172.217.7.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 20ms, Average = 15ms
C:\Documents and Settings\InterLinked>
我改Bridged
回NAT
:
C:\Documents and Settings\InterLinked>ping google.com
Pinging google.com [172.217.7.14] with 32 bytes of data:
Reply from 172.217.7.14: bytes=32 time=15ms TTL=47
Destination host unreachable.
Destination host unreachable.
Destination host unreachable.
Ping statistics for 172.217.7.14:
Packets: Sent = 4, Received = 1, Lost = 3 (75% loss),
Approximate round trip times in milli-seconds:
Minimum = 15ms, Maximum = 15ms, Average = 15ms
C:\Documents and Settings\InterLinked>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
C:\Documents and Settings\InterLinked>ping google.com
Pinging google.com [172.217.7.14] with 32 bytes of data:
Reply from 172.217.7.14: bytes=32 time=12ms TTL=47
Reply from 172.217.7.14: bytes=32 time=6ms TTL=47
Reply from 172.217.7.14: bytes=32 time=188ms TTL=47
Reply from 172.217.7.14: bytes=32 time=14ms TTL=47
Ping statistics for 172.217.7.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 6ms, Maximum = 188ms, Average = 55ms
C:\Documents and Settings\InterLinked>
如前所述,启用VirtualBox DNS解析器是解决方案。
具体步骤如下:
cd C:\Program Files\Oracle\VirtualBox
VBoxManage modifyvm "<VM name>" --natdnshostresolver1 on
<VM name>
只是VM的名称,也可以通过运行找到它VBoxManage list runningvms
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句