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

Remote device unreachable in WSL2 when internet connection sharing is enabled #8428

Closed
tan-wei-xin-alez opened this issue May 20, 2022 · 3 comments
Labels

Comments

@tan-wei-xin-alez
Copy link

tan-wei-xin-alez commented May 20, 2022

Version

Microsoft Windows [Version 10.0.19042.1466]

WSL Version

WSL2

Kernel Version

Linux version 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220)

Distro Version

Distributor ID: Ubuntu
Description: Ubuntu Jammy Jellyfish (development branch)
Release: 22.04
Codename: jammy

Other Software

No response

Repro Steps

  1. Install and set up WSL2 on local device
  2. Set up an ethernet connection between local and remote device
  3. Set remote device IP statically to 192.168.137.150
  4. Set local device IP statically to 192.168.137.1
  5. Confirm remote device is reachable from local device with wsl ping 192.168.137.150
  6. Set up ethernet or wi-fi connect to internet (mine was using wi-fi)
  7. Enable internet connection sharing (ICS) with remote device via "Network Connections"→Properties→Sharing→"Allow other network users to connect through this computer's internet connection"→(select "Home networking connection" corresponding to network adapter used to connect to remote device)→OK
  8. Try wsl ping 192.168.137.150 again (will fail due to "Hyper-V Virtual Ethernet Adapter" being on wrong network)
  9. Open powershell or cmd and try ping 192.168.137.150 which will work
  10. Set "Hyper-V Virtual Ethernet Adapter" IP statically to 192.168.137.25
  11. Try wsl ping 192.168.137.150 again (will still fail even though on correct network as seen below)
PING 192.168.137.150 (192.168.137.150) 56(84) bytes of data.
From 192.168.137.25 icmp_seq=1 Destination Host Unreachable
From 192.168.137.25 icmp_seq=2 Destination Host Unreachable
From 192.168.137.25 icmp_seq=3 Destination Host Unreachable

I've tried a bunch of things like port forwarding with netsh as seen at
#4150 (comment)
and
https://lifesaver.codes/answer/static-ip-on-wsl-2-418
as well as using
https://github.com/wikiped/WSL-IpHandler
to set the IP of wsl instances statically but the remote device becomes unreachable the moment ICS is enabled

Update

Internet connection in WSL2 is completely lost once ICS is enabled

  • Before enabling ICS,
    • in powershell
    Pinging google.com [142.250.184.238] with 32 bytes of data:
    Reply from 142.250.184.238: bytes=32 time=15ms TTL=58
    Reply from 142.250.184.238: bytes=32 time=37ms TTL=58
    Reply from 142.250.184.238: bytes=32 time=15ms TTL=58
    
    Ping statistics for 142.250.184.238:
        Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 15ms, Maximum = 37ms, Average = 22ms
    
    • in WSL2
    PING google.com (142.250.74.206) 56(84) bytes of data.
    64 bytes from fra24s02-in-f14.1e100.net (142.250.74.206): icmp_seq=1 ttl=57 time=16.3 ms
    64 bytes from fra24s02-in-f14.1e100.net (142.250.74.206): icmp_seq=2 ttl=57 time=17.1 ms
    64 bytes from fra24s02-in-f14.1e100.net (142.250.74.206): icmp_seq=3 ttl=57 time=16.1 ms
    64 bytes from fra24s02-in-f14.1e100.net (142.250.74.206): icmp_seq=4 ttl=57 time=22.8 ms
    
    --- google.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3005ms
    rtt min/avg/max/mdev = 16.128/18.093/22.841/2.766 ms
    
  • After enabling ICS
    • in powershell
    Pinging google.com [142.250.74.206] with 32 bytes of data:
    Reply from 142.250.74.206: bytes=32 time=16ms TTL=58
    Reply from 142.250.74.206: bytes=32 time=15ms TTL=58
    Reply from 142.250.74.206: bytes=32 time=16ms TTL=58
    
    Ping statistics for 142.250.74.206:
        Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 15ms, Maximum = 16ms, Average = 15ms
    
    • in WSL2
    PING google.com (142.250.74.206) 56(84) bytes of data.
    From host.docker.internal (192.168.178.25) icmp_seq=3 Destination Host Unreachable
    From host.docker.internal (192.168.178.25) icmp_seq=6 Destination Host Unreachable
    From host.docker.internal (192.168.178.25) icmp_seq=9 Destination Host Unreachable
    
    --- google.com ping statistics ---
    10 packets transmitted, 0 received, +3 errors, 100% packet loss, time 9263ms
    

I'm guessing network routing gets broken by ICS and manual setup is required but I have not been able to figure out how to do it yet (simple port forwarding with netsh does not seem to work)

Expected Behavior

Should be able to reach remote device when on same network regardless of whether ICS is enabled or not

Update

Internet access within WSL2 should be preserved regardless of whether ICS is enabled or not

Actual Behavior

Unable to reach remote device from within WSL2 but no problems whatsoever from Windows itself

Update

Internet access is lost within WSL2 when ICS is enabled

Diagnostic Logs

No response

@tan-wei-xin-alez tan-wei-xin-alez changed the title Host unreachable in WSL2 when internet connection sharing is enabled Remote device unreachable in WSL2 when internet connection sharing is enabled May 20, 2022
@tan-wei-xin-alez
Copy link
Author

Seems like ICS is required for WSL2 to function as mentioned in #6646 but it really should not cut off internet access in it when ICS is being used for another network adapter

@ghost ghost added the network label May 24, 2022
@rhoot
Copy link

rhoot commented Jul 21, 2023

This issue alone has been keeping me on WSL1 and unable to upgrade. I have a few devices that rely on ICS on my PC for VPN connectivity. Using WSL2 causes those devices to not be able to connect. On the other hand WSL1 is also starting to have a lot of issues (e.g gdb not working reliably).

Is there a workaround that can be used to allow ICS to be used while also using WSL2?

Edit: Turns out I misremembered what the issue is. The problem is that network connectivity will seemingly randomly use one of my other network adapters for outbound traffic. Sometimes it picks the VPN adapter, other times it picks my physical adapter. Meaning I sometimes can access the internet. sometimes not. Sometimes I can access the internal network, sometimes not.

But if anyone else bumps into this and have the same issue, I bumped into wsl-vpnkit which seems to have just magically fixed my connectivity issues. While still using internet connection sharing for my other devices.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

2 participants