Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL 2 USB Tethering Network issue #5313

Open
SuhasHebbar opened this issue Jun 1, 2020 · 35 comments
Open

WSL 2 USB Tethering Network issue #5313

SuhasHebbar opened this issue Jun 1, 2020 · 35 comments
Labels

Comments

@SuhasHebbar
Copy link

SuhasHebbar commented Jun 1, 2020

  • Your Windows build number: Microsoft Windows [Version 10.0.19041.264]

  • What you're doing and what's happening:

  1. Set up Mobile USB tethering
  2. Ensure internet connectivity (Google search)
  3. Open the Debian terminal
  4. Run traceroute command
$ traceroute google.com
traceroute to google.com (216.58.200.142), 30 hops max, 60 byte packets
 1  DESKTOP-1SAJ81T.mshome.net (172.27.32.1)  0.641 ms  0.618 ms  0.597 ms
 2  * * *
 3  * * *
 4  * * *
....
# Continues till 30 and exits

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

  • What's wrong / what should be happening instead:
    So effectively no internet access in WSL 2 while USB Tethering..
    traceroute works fine with only the WiFi connected.
$ 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
Copy link
Author

SuhasHebbar commented Jun 4, 2020

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
Copy link
Collaborator

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
Copy link

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
Copy link

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

@irakan
Copy link

irakan commented Oct 10, 2020

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
Copy link

irakan commented Oct 10, 2020

related issue here as well #5827

@Aleksanaa
Copy link

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
Copy link

QvQQ commented Nov 16, 2020

still

@Vinche59
Copy link

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

@rajmondx
Copy link

rajmondx commented Dec 22, 2020

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

@GabboM
Copy link

GabboM commented Feb 11, 2021

same

@balciseri
Copy link

Still....

@Ameynm
Copy link

Ameynm commented May 27, 2021

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
Copy link

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
Copy link

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
Copy link

Ameynm commented Jun 17, 2021

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
Copy link

IhateTrains commented Dec 19, 2021

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

@iamzubin
Copy link

iamzubin commented Mar 2, 2022

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

@busybox0
Copy link

not yet fixed for windows 10

@veldfolds
Copy link

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

@MichaelUrman
Copy link

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)
> 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:

  • my wired connection is interface 3, 192.168.1.* (per ipconfig.exe)
  • my wifi uses interface 10, possibly also 11 and/or 13 192.168.151.* (per ipconfig.exe)
  • routes with gateway follow different patterns in IPv4 and IPv6
    • IPv6 only has a gateway route for interface 10
    • IPv4 has one for each; interface 3's gateway route has a lower metric than interface 10's

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
Copy link

Broken on Windows 11 22621.674

@Turom
Copy link

Turom commented Aug 3, 2023

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
Copy link

gc1o1 commented Sep 6, 2023

Still broken on Windows 11 build 22621.2134

@Trecto34
Copy link

Still broken

@chanpreetdhanjal
Copy link

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

@VibingCreator
Copy link

It's been broken for 4 years. Any solutions for Windows 10?

@Aleksanaa
Copy link

It's been broken for 4 years. Any solutions for Windows 10?

My friend. Format windows and install Linux. The next time this happens, a helpful netizen will have given you a patch, and the patch will be merged within a few weeks.

@sequencerr
Copy link

@Aleksanaa I want to thank wsl, it made me switch to Linux. And this was exactly what I did

@VibingCreator
Copy link

VibingCreator commented Oct 25, 2024

It's been broken for 4 years. Any solutions for Windows 10?

My friend. Format windows and install Linux. The next time this happens, a helpful netizen will have given you a patch, and the patch will be merged within a few weeks.

I had been using Linux for development purposes but then switched back to Windows and WSL. That was my biggest life mistake.

@MaxKosova
Copy link

@VibingCreator

It's been broken for 4 years. Any solutions for Windows 10?

It's difficult to reproduce. I encountered this issue in the past on only one device, which was running WSL 1 (on Win 10). Since upgrading to WSL 2, I haven't experienced it anymore.

@dliakh
Copy link

dliakh commented Oct 27, 2024

For me that is reproduceable in 100% cases: just connecting the PC to the Internet with a USB dongle (phone), starting WSL and that's it: "No Internet Connection"
It looks like anything using Hyper-V causes that: starting the "Windows Sandbox" or a Hyper-V virtual machine also leads to the same effect

@MaxKosova
Copy link

For me that is reproduceable in 100% cases: just connecting the PC to the Internet with a USB dongle (phone), starting WSL and that's it: "No Internet Connection" It looks like anything using Hyper-V causes that: starting the "Windows Sandbox" or a Hyper-V virtual machine also leads to the same effect

First, there is no error message that says "No Internet Connection." Second, what you are describing sounds like a bug you’re experiencing (on your device), but we need more information to reproduce it. When I follow your instructions, I don’t encounter any "no internet connection" issue.

The easiest way to help would be to upload a virtual machine or Docker file, so everyone can work with the exact environment where the bug occurs.

@VibingCreator
Copy link

VibingCreator commented Oct 28, 2024

@VibingCreator

It's been broken for 4 years. Any solutions for Windows 10?

It's difficult to reproduce. I encountered this issue in the past on only one device, which was running WSL 1 (on Win 10). Since upgrading to WSL 2, I haven't experienced it anymore.

So basically, I am plugging in the android device to my PC with enabled tethering. On my host machine it works fine but when I enter WSL, there's no internet access. It's probably because WSL doesn't care about my networks except Ethernet (hence one adapter vEthernet). I have tried internet connection sharing directly to the vEthernet adapter and I have got to say it worked, kind of. WSL had access to the internet but it was not reliable at all. Huge packet losses and 3000 ms for a request to hit back.

As far as I know, WSL introduced network mirroring for latest WSL but only for Windows 11.

WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.19045.5011

@dliakh
Copy link

dliakh commented Oct 28, 2024

Yes, that's not only happening when "tethering" Android devices but any "RNDIS" device, it seems (tried that connecting to a non-smartphone that can provide "USB ethernet" (an Alcatel 3080g 4G phone which is not running Android) and the same happens as described above.
Moreover: that doesn't even look specific to WSL but seems to be happening when using anything based on Hyper-V (i.e. opening the "Windows Sandbox" or starting a Hyper-V virtual machine -- the same effect)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests