WSL icon indicating copy to clipboard operation
WSL copied to clipboard

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

Open ZikaZaki opened this issue 2 years ago • 19 comments

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?

  • [X] WSL 2
  • [ ] WSL 1

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

ZikaZaki avatar May 27 '23 21:05 ZikaZaki

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

jeremydierx avatar May 30 '23 08:05 jeremydierx

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

ZikaZaki avatar May 30 '23 22:05 ZikaZaki

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...

jeremydierx avatar Jun 29 '23 07:06 jeremydierx

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" ?

keith-horton avatar Jul 03 '23 19:07 keith-horton

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

tonyhabib01 avatar Sep 26 '23 07:09 tonyhabib01

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 avatar Oct 27 '23 00:10 francip

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

francip avatar Oct 27 '23 00:10 francip

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

keith-horton avatar Oct 27 '23 01:10 keith-horton

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.

  1. 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

vvavrychuk avatar Jan 29 '24 16:01 vvavrychuk

Experincing same issue

  • WSL2
  • iPhone 13 Pro
  • iOS 18.1.1
  • Microsoft Windows 11 Pro
  • Version 10.0.22631 Build 22631

How can I help?

LuckyLub avatar Dec 06 '24 15:12 LuckyLub

hi, if you are experiencing the issue can you please collect networking logs using the instructions here. The script will generate a zip with name starting with "WslNetworkingLogs"

thanks

CatalinFetoiu avatar Dec 07 '24 02:12 CatalinFetoiu

I have the same problem recently. It's like another problem I had occurred before, which is network broken when VPN is on. And it turns out that the same solution for VPN also works for this Mobile WiFi Hotspot issue: https://github.com/sakai135/wsl-vpnkit

link89 avatar Dec 09 '24 01:12 link89

I can confirm that the wsl-vpnkit is working for me.

I made logs according to description and emailed a download link to [email protected], since I felt uncomfortable sharing it here.

  • I pinged 8.8.8.8 3 times. Unsuccessfully.
  • after which I enable the vpn kit and pinged 8.8.8.8 3 more times. Successfully.
  • After that I disabled the vpn kit and pinged 8.8.8.8 3 more times. Unsuccessfully.

LuckyLub avatar Dec 20 '24 07:12 LuckyLub

@LuckyLub can you please send a copy or download link of the networking logs to [email protected] instead? Thanks. (this is the alias where users can send us logs)

CatalinFetoiu avatar Jan 04 '25 01:01 CatalinFetoiu

Hi, sorry missed that message @CatalinFetoiu, but I am running into this issue again. I have sent the previous logs and new logs that I created just now to [email protected].

LuckyLub avatar Apr 25 '25 09:04 LuckyLub

Thanks @LuckyLub . The link you gave was to a site I don't have access to. Do you have a OneDrive or GoogleDrive link perhaps?

keith-horton avatar May 01 '25 02:05 keith-horton

Hi @keith-horton, retried it just now.

LuckyLub avatar May 09 '25 11:05 LuckyLub

@LuckyLub : thanks. There are lots of WinNat errors. it's not clear where winnat is not working with Hotspot supports. I don't see a Hotspot interface being created - which suggests there's a separate driver / interface configuration breaking things :(

Are you able to enable networking mode = Mirroring instead of NAT?

keith-horton avatar May 09 '25 19:05 keith-horton

Awesome thanks! Yes changing the networking mode from NAT to mirrored fixed it for me. I was not aware this was an option.

LuckyLub avatar May 16 '25 05:05 LuckyLub