microsoft / WSL

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

WSL 2 USB Tethering Network issue #5313

Open SuhasHebbar opened 4 years ago

SuhasHebbar commented 4 years ago

Note: These steps were performed on a fresh distro setup with traceroute installed (sudo apt-get install traceroute).

$ traceroute google.com
traceroute to google.com (172.217.163.174), 30 hops max, 60 byte packets
 1  DESKTOP-1SAJ81T.mshome.net (172.27.32.1)  0.654 ms  1.066 ms  1.435 ms
 2  jiofi.local.html (192.168.225.1)  6.198 ms  6.440 ms  6.350 ms
 3  * * *
 4  10.72.169.2 (10.72.169.2)  68.503 ms 10.72.169.3 (10.72.169.3)  68.387 ms 10.72.169.2 (10.72.169.2)  68.432 ms
 5  172.25.118.70 (172.25.118.70)  68.243 ms 172.25.118.66 (172.25.118.66)  76.562 ms  68.183 ms
 6  172.25.118.73 (172.25.118.73)  76.428 ms 172.25.118.67 (172.25.118.67)  48.591 ms  48.473 ms
 7  172.17.113.38 (172.17.113.38)  48.481 ms 172.17.113.34 (172.17.113.34)  48.382 ms  61.860 ms
 8  * * *
 9  * * *
10  * * *
11  * * *
12  74.125.242.145 (74.125.242.145)  49.613 ms *  104.558 ms
13  74.125.252.91 (74.125.252.91)  94.414 ms 209.85.248.218 (209.85.248.218)  110.462 ms 209.85.248.181 (209.85.248.181)  104.337 ms
14  maa05s05-in-f14.1e100.net (172.217.163.174)  110.395 ms  116.519 ms  110.281 ms

I've put the output of ipconfig and Get-NetAdapter with either WiFi or USB Tethering in a gist in case it is relevant.

USB Tethering creates a temporary network interface (in my case "Ethernet 2") that is deleted on disconnecting. This interface is not present on boot/login.

SuhasHebbar commented 4 years ago

Okay since this issue was really eating away at my mind I decided to take a look at the "vEthernet (WSL)" interface with Wireshark.

image

Seeing the above in the capture log I took a look at the ARP table with Get-NetNeighbor -AddressFamily IPv4 -InterfaceIndex 46 which gave me 28 192.168.42.129 00-00-00-00-00-00 Unreachable ActiveStore. I am pretty sure the the MAC address (of the default gateway of the usb tethering network) is not 00-00-00-00-00-00. Though since this entry is not permanent I cannot change it with Set-NetNeighbor.

Just mentioning this in case it is relevant to the issue.

therealkenc commented 3 years ago

Please collect WSL logs and post the backlink to the feedback item here. Also please identify any third-party networking software that has been installed on Windows.

inquirnigmind commented 3 years ago

Please collect WSL logs and post the backlink to the feedback item here. Also please identify any third-party networking software that has been installed on Windows.

I am not sure what WSL logs would be relevant as not much is seen when re-creating the problem. When I ping www.google.com it just hangs at "PING www.google.com (172.217.9.196) 56(84) bytes of data." until I kill the command and it returns some variant of "59 packets transmitted, 0 received, 100% packet loss, time 60330ms". The same with if pinging 8.8.8.4. A sudo apt-get update eventually returns a connection timed out error.

Previously, Cisco Anyconnect and SonicWall VPNs were previously installed (removed as no longer in use), PIA VPN was temporarily removed, and Comodo firewall was also removed. Windows firewall is on. VMWare 15 is installed which created two virtual network adapters. As SuhasHebbar mentioned above the tethered USB network interface is temporary and is deleted when the MiFi is turned off/unplugged.

Aleksanaa commented 3 years ago

Same issue here.I use a android phone to share its connection.

irakan commented 3 years ago

I am facing the same issue as well

for example when trying to do apt-get install net-tools in wsl 2, the command manage to execute for 1 second, after that, the entire computer network crashes and stops ( wsl2 + windows host )

I am using 20231.1000 dev build

irakan commented 3 years ago

related issue here as well #5827

Aleksanaa commented 3 years ago

The issue still exists with the latest update.

I am facing the same issue as well

for example when trying to do apt-get install net-tools in wsl 2, the command manage to execute for 1 second, after that, the entire computer network crashes and stops ( wsl2 + windows host )

I am using 20231.1000 dev build

QvQQ commented 3 years ago

still

Vinche59 commented 3 years ago

Same problem here .... WSL Logs : https://aka.ms/AAae48d

rajmondx commented 3 years ago

I'm seeing the same issue...

@therealkenc There are too many things to consider, but basically what I did:

Not taking Bluetooth/WiFi into account: At the end I was left with only 1 network adapter (+ the one generated by HyperV for WSL). It still didnt work.

hint. I "log" all my changes I do to my Windows (+WSL) in a file and it all started happening when I updated from WSL1 to WSL2 but at the same time I was installing other software too (eg. Docker, which is why I upgraded to WSL2 in the first place).

Things to consider (or lets say "which are strange"):

but tbh I have absolutely 0 clue whats going on and even less regarding networking in general

My current workaround:

  1. Share your network adapter with "vEthernet (WSL)" (or whatever adapter your WSL is running with) Control panel > Network and Internet > Network Sharing Center > Change adapter settings > Right click Properties > (In new window) select tab "Sharing" > Select WSL adapter to share with.
  2. Disable in wsl.conf "auto resolving" and setup your nic manually (resolv.conf) and use from now on a static ip
  3. Keep in mind that resolv.conf has to share the exactly same settings (dns server and ip address) as the windows host or otherwise it will "shutdown the network" as well

After doing this your WSL should share the same nic as your windows (so even tunneling with vpns work).

GabboM commented 3 years ago

same

balciseri commented 3 years ago

Still....

Ameynm commented 3 years ago

what worked for my Android is installing Easytether on my Xiaomi android device and also on pc.

http://www.mobile-stream.com/easytether/android.html

I don't know why it worked but I guess it uses its own RNDIS driver than using default Windows driver. Because when I ran WSL on my pc and tried to install a package, my pc used to disconnect the tethering and show me no network connected, even though my device is tethering from its side. same thing happened with different device (Vivo)

installing a different tethering worked for me.

Aleksanaa commented 3 years ago

what worked for my Android is installing Easytether on my Xiaomi android device and also on pc.

http://www.mobile-stream.com/easytether/android.html

I don't know why it worked but I guess it uses its own RNDIS driver than using default Windows driver. Because when I ran WSL on my pc and tried to install a package, my pc used to disconnect the tethering and show me no network connected, even though my device is tethering from its side. same thing happened with different device (Vivo)

installing a different tethering worked for me.

It works!Thank you so much! In addition,this software doesn't provide https connection unless you pay for it.But you can find a tool to generate register code in easytether-keygen

superromeo commented 3 years ago

Same thing:

I'm seeing the same issue...

@therealkenc There are too many things to consider, but basically what I did:

  • Removed cFosSpeed (comes bundled with MSI Motherboards)
  • Deactivated all security features and firewall options
  • Deactivated everything regarding networking in BIOS
  • Removed all "items" a connection can have in the network properties (basically only bridge+ipv4 was enabled)

    • Removed all networks
  • Removed network devices (even the hidden ones)

Not taking Bluetooth/WiFi into account: At the end I was left with only 1 network adapter (+ the one generated by HyperV for WSL). It still didnt work.

hint. I "log" all my changes I do to my Windows (+WSL) in a file and it all started happening when I updated from WSL1 to WSL2 but at the same time I was installing other software too (eg. Docker, which is why I upgraded to WSL2 in the first place).

Things to consider (or lets say "which are strange"):

  • The issue only happens when usb tethering is used (doesnt happen in wifi or over "normal" LAN)
  • Pinging "barely" works (sometimes with 1k+ ms) but everything else (like downloading a small txt through wget) will "shutdown my internet" (even on the host)
  • Using the internet on the host (windows) works fine (as long as nothing happens in WSL2)
  • USB Tethering works with other phones (but not with my Samsung Galaxy S8 Android 8.0.0) and yes both are using the same driver for the network adapter in windows (SAMSUNG Mobile USB Remote NDIS Network Device)
  • ~When running Gradle (on openjdk11) on the host (windows!) will do the same shit = "shutting down" network (but this has probably something to do when using Windows builtin wifi tethering)~
  • And another strange thing: I'm using OpenVPN (while working) and ofc same thing happens there too buuuuuut im able to ping the "local ip addresses" within the vpn without any lag, hell im even able to use wget or git (through ssh) in that local vpn BUT if I try to do the same with "public ip addresses" it will "shutdown" my network)
  • It doesnt affect docker containers - they still work as expected (afaik Docker and WSL2 both use HyperV as backend so the problem actually doesnt seem to be related to network adapters )

    • even runned some docker-composes (creates a own network)

but tbh I have absolutely 0 clue whats going on and even less regarding networking in general

My current workaround:

  1. Share your network adapter with "vEthernet (WSL)" (or whatever adapter your WSL is running with) Control panel > Network and Internet > Network Sharing Center > Change adapter settings > Right click Properties > (In new window) select tab "Sharing" > Select WSL adapter to share with.
  2. Disable in wsl.conf "auto resolving" and setup your nic manually (resolv.conf) and use from now on a static ip
  3. Keep in mind that resolv.conf has to share the exactly same settings (dns server and ip address) as the windows host or otherwise it will "shutdown the network" as well

After doing this your WSL should share the same nic as your windows (so even tunneling with vpns work).

Ameynm commented 3 years ago

what worked for my Android is installing Easytether on my Xiaomi android device and also on pc. http://www.mobile-stream.com/easytether/android.html I don't know why it worked but I guess it uses its own RNDIS driver than using default Windows driver. Because when I ran WSL on my pc and tried to install a package, my pc used to disconnect the tethering and show me no network connected, even though my device is tethering from its side. same thing happened with different device (Vivo) installing a different tethering worked for me.

It works!Thank you so much! In addition,this software doesn't provide https connection unless you pay for it.But you can find a tool to generate register code in easytether-keygen

Thanks to you to. apparently you can use the same tool on Linux too have you tried using it on WSL?

IhateTrains commented 2 years ago

Having the same issue on Windows 11. EDIT: Seems to be fixed as of Windows 11 build 22000.466.

iamzubin commented 2 years ago

wait, I don't want to update to windows 11 I'm still facing the same issue

busybox0 commented 2 years ago

not yet fixed for windows 10

veldfolds commented 1 year ago

They no longer care about windows 10 and yet this thing is frustrating. If wifi works why not tethering

MichaelUrman commented 1 year ago

I'm not sure it's quite the same issue, but since it's like #6121, I suspect it shares underlying problems. And I have a worked-once-for-me fix: TLDR; adjust route metrics with route.exe change ....

My normal internet connection (wired) went down so I connected to a wifi-hotspot. This got Windows (Edge, etc.) back in business. But WSL didn't pick up on the change. Gather some information from netstat.

netstat.exe -rn (filtered output) ```console > netstat.exe -rn =========================================================================== Interface List 46...[REDACTED] d4 ......Hyper-V Virtual Ethernet Adapter 3...[REDACTED] bb ......Realtek USB GbE Family Controller #2 11...[REDACTED] 1a ......Microsoft Wi-Fi Direct Virtual Adapter 13...[REDACTED] 19 ......Microsoft Wi-Fi Direct Virtual Adapter #2 10...[REDACTED] 19 ......Intel(R) Wi-Fi 6 AX201 160MHz 1...........................Software Loopback Interface 1 =========================================================================== IPv4 Route Table =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.136 25 0.0.0.0 0.0.0.0 192.168.151.74 192.168.151.81 50 192.168.1.0 255.255.255.0 On-link 192.168.1.136 281 192.168.151.255 255.255.255.255 On-link 192.168.151.81 306 [...] =========================================================================== Persistent Routes: None IPv6 Route Table =========================================================================== Active Routes: If Metric Network Destination Gateway 10 66 ::/0 fe80::a4e4:7ff:fe6f:e60 10 306 fe80::/64 On-link 3 281 fe80::/64 On-link 46 271 fe80::/64 On-link 3 281 fe80::10d9:cacd:4eac:2d92/128 [...] =========================================================================== Persistent Routes: None ```

Of note:

Normally those IPv4 metrics would make sense, but not while the internet is unreachable through interface 3. So I found that this route.exe change ... command helped. (Modify the 192.168.1.1, 27, and/or 3 below per your netstat output. Omit the warning symbols. Requires Administrator.)

> route.exe change 0.0.0.0 mask 0.0.0.0 ⚠192.168.1.1⚠ metric ⚠27⚠ IF ⚠3⚠
 OK!

The values are mostly direct from the from the IPv4 route table, with a carefully chosen metric addition (27) to make the wired gateway less attractive (25+27>50), applied explicitly to the wired interface (3). With the wireless route more attractive, wsl's curl -o /dev/null https://github.com works quickly. Setting the metric back (or as near as I could: route change ... metric 1 IF 3), curl times out and reports "Could not resolve host github.com".

I don't know what the underlying problem is. It could be that Windows didn't drop the wired IPv4 route when it identified the internet was unavailable. It could be that it applies bad metrics. It could be that Edge uses IPv6 while WSL uses IPv4. Or something else. But changing the metric got me up and running without any restarts.

And, just in time, my wired internet came back. Without having to further modify the above, networking from WSL is still functional, both before and after disabling WIFI. (It may help that the next lowest metric is around 271, so there's plenty of wiggle room.) Why didn't I just disable the wired connection? Well, that's how I was remoting the laptop that could use my wifi hotspot... 😅

anthonygerrard commented 1 year ago

Broken on Windows 11 22621.674

Turom commented 11 months ago

Windows 11 22621.1992, still not working Phone is XPeria 1 III, WSL 2 can't reach network both on USB tether and WiFi hotspot

gc1o1 commented 9 months ago

Still broken on Windows 11 build 22621.2134

Trecto34 commented 2 months ago

Still broken

chanpreetdhanjal commented 2 months ago

Hi. Can you please collect networking logs by following the instructions below? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues