microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.51k stars 822 forks source link

[BUG] WSL2 loses internet connection when Mobile Hotspt is turned on #10146

Open ZikaZaki opened 1 year ago

ZikaZaki commented 1 year ago

Windows Version

Microsoft Windows 11 [Version 21H2] [OS Build 22000.1936)

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.90.1

Distro Version

Ubuntu 20.04

Other Software

Visual Studio Code 1.77.2 with Remote WSL-Extension 0.77.0

Repro Steps

  1. Open WSL2 on a Windows 11 machine.
  2. Connect to the internet.
  3. Turn on Mobile Hotspot on the same Windows 11 machine.
  4. Observe that the WSL2 loses internet connection.

Expected Behavior

The WSL2 should maintain its internet connection when the Mobile Hotspot is turned on in the Windows 11 machine.

Actual Behavior

When a user turns on Mobile Hotspot on their Windows 11 machine, the WSL2 loses internet connection and is unable to connect to any external network resources. The WSL2 network adapter appears to be disconnected and cannot be reconnected until the Mobile Hotspot is turned off.

:exclamation: NOTE: This bug only affects WSL2 and NOT the Windows host machine.

Example: Running the sudo apt update && sudo apt upgrade command will fail to update the packages and report errors, as shown below in the screenshots.

Screenshots

wsl bug wsl bug 2

Diagnostic Logs

No response

jeremydierx commented 1 year ago

Same issue from Windows 11 / Wsl2. Have you solved it?

ZikaZaki commented 1 year ago

@jeremydierx not yet, I'm trying to figure it out.

jeremydierx commented 1 year ago

New! Connection sharing with WSL does not work with my iphone 12 mini but works with my Huawei 30 pro. So the problem is related to the iPhone and I think it comes from the latest update from Apple...

keith-horton commented 1 year ago

This sounds like 2 different configurations: one is enabling Hotspot so other devices can connect through this host device running WSL; the other scenario is having the host device connect through another phone as its network connection. Is that right?

In both cases, can you please share the host ip connectivity state? "Get-NetIPInterface", "Get-NetRoute" ?

tonyhabib01 commented 1 year ago

@ZikaZaki I have the same problem, have you solve it ?

francip commented 1 year ago

This reproes with WSL2 on Windows 11 tethered to an iPhone 15 Pro Max. Windows has full connectivity to internet:

PS C:\Users\Franci Penov\src\dashai> git pull
Already up to date.

Ubuntu in WSL2 cannot connect:

francip francip-laptop ~/src/dashai [git main] $ git pull
fatal: unable to access 'https://github.com/francip/dashai.git/': Failed to connect to github.com port 443 after 154 ms: No route to host
francip commented 1 year ago

Restarting WSL2 does not help. Get-NetIPInterface in the host:

PS C:\Users\Franci Penov\src\dashai> Get-NetIPInterface

ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
40      vEthernet (WSL)                 IPv6                  1500              15 Enabled  Connected       ActiveStore
14      Local Area Connection* 2        IPv6                  1500              25 Disabled Disconnected    ActiveStore
10      Bluetooth Network Connection    IPv6                  1500              65 Disabled Disconnected    ActiveStore
7       Local Area Connection* 1        IPv6                  1500              25 Disabled Disconnected    ActiveStore
8       Ethernet                        IPv6                  1500               5 Enabled  Disconnected    ActiveStore
17      Wi-Fi                           IPv6                  1440              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv6            4294967295              75 Disabled Connected       ActiveStore
40      vEthernet (WSL)                 IPv4                  1500              15 Disabled Connected       ActiveStore
14      Local Area Connection* 2        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
10      Bluetooth Network Connection    IPv4                  1500              65 Enabled  Disconnected    ActiveStore
7       Local Area Connection* 1        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
8       Ethernet                        IPv4                  1500               5 Enabled  Disconnected    ActiveStore
17      Wi-Fi                           IPv4                  1500              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv4            4294967295              75 Disabled Connected       ActiveStore

Also, in Control Panel:

wsl-disconnected

keith-horton commented 1 year ago

Hi there. we'll need a trace to see what's going on. Can you please run this - then startup the WSL container (while traces are running)? Here's the link to our script: https://github.com/microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1

Can you also run "netsh nlm query all nlmquery.log" - and attach that log file with the above traces?

Thanks

vvavrychuk commented 10 months ago

For me steps to reproduce are a bit more complicated:

  1. Connect to Ethernet, verify WSL has Internet:

    > traceroute 1.1.1.1
    traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
    1  HOSTNAME (172.24.32.1)  0.340 ms  0.309 ms  0.303 ms
    2  192.168.0.1 (192.168.0.1)  1.096 ms  1.834 ms  1.829 ms
    ...

    Here 172.24.32.1 is my "vEthernet (WSL)" IP and 192.168.0.1 is my router IP address.

  2. Disconnect from Ethernet and connect to Wi-Fi, verify WSL has Internet:

    > traceroute 1.1.1.1
    traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
    1  HOSTNAME (172.24.32.1)  0.247 ms  0.227 ms  0.222 ms
    2  router.lan (192.168.1.1)  2.683 ms  2.679 ms  2.830 ms

192.168.1.1 is my another router IP address.

  1. Enable "Mobile hotspot", WSL has no internet anymore
    > traceroute 1.1.1.1
    traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
    1  HOSTNAME (172.24.32.1)  0.291 ms  0.256 ms  0.251 ms
    2  192.168.0.5 (192.168.0.5)  1782.022 ms !H * *

192.168.0.5 used to be my ethernet adapte IP address when I was connected to Ethernet.

Workaround

> Remove-NetRoute -DestinationPrefix 0.0.0.0/0 -InterfaceIndex 5

FYI @keith-horton