Wi-Fi 的 VirtualBox 網路適配器/DNS 問題

Wi-Fi 的 VirtualBox 網路適配器/DNS 問題

我在使用 VirtualBox 時遇到了一個非常奇怪的問題。

大多數時候,我的筆記型電腦都硬連線到乙太網路連線。有時,當我離開辦公桌時,除了 Wi-Fi 之外我別無選擇。連接到 Wi-Fi 時,我的主機(Windows 10)在幾秒鐘內即可存取網絡,沒有任何問題。但是,來賓 (Windows XP SP3) 將表現得好像仍處於離線狀態。

我在 VirtualBox 中的網路配置是NAT.

奇怪的是,這只發生在無線網路上。每當我對電腦進行硬連線時,主機作業系統絕不任何取得網路連線時出現問題。我將其設定為 NAT,因為我需要來賓作業系統能夠存取 Internet,但我不希望主機外部的客戶端連接到它。我也不想將訪客電腦綁定到有線網卡或無線網卡,因為這樣它只能在其中一個上工作。

另一方面,每當我連接到 Wi-Fi 時,都會出現總是從客人那裡獲取網路連線時出現問題。

有一次我遇到問題,我打字ipconfig /flushdns,突然一切正常了。從那時起,這還不夠。刷新我的 DNS 不足以讓 Wi-Fi 上正常運作。

我發現強制它工作的唯一方法是進入來賓的 VirtualBox 設定並將網路適配器從 更改NATBridged。到了這個地步,還是不行。然而,現在如果我ipconfig /flushdns(在訪客上)輸入,一切都會突然正常:我可以存取網路。更奇怪的是我現在可以把它改回NAT.突然間,它會停止工作,但是如果我停止工作ipconfig /flushdns 再次,它會起作用。

換句話說,我兜了一圈又回到了NAT最終有效的聯繫。開始和結束狀態是完全一樣,所以我很困惑為什麼來賓無法自行獲得網路連線。如果我只需要ipconfig /flushdns在連接 Wi-Fi 時鍵入,那是一回事,但必須退出來賓並將適配器從 更改為NATBridged然後再更改回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
.

更改NATBridged並重試:

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>

我改BridgedNAT

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>

答案1

如所暗示的,啟用 VirtualBox DNS 解析器就是解決方案。

以下是具體步驟:

  1. 關閉虛擬機器。機器開啟時無法開啟 DNS 解析器。
  2. 導覽至 VirtualBox 目錄主持人從命令提示字元處:cd C:\Program Files\Oracle\VirtualBox
  3. 運行以下命令:VBoxManage modifyvm "<VM name>" --natdnshostresolver1 on

<VM name>只是VM的名稱,VBoxManage list runningvms也可以透過運行找到。

相關內容