Giter Club home page Giter Club logo

wslhostpatcher's Introduction

WSLHostPatcher

Dynamic patch WSL2 to listen port on any interfaces.

Updates

Check out experimental bridge solution at microsoft/WSL#4150 (comment).

Also MS official config for WSL 2 in Windows Build 19041 and later.

How it work

The localhost port actually forward by wslhost.exe on Windows, but it listen on localhost only.

WSLHostPatcher will scan all wslhost.exe processes, then inject into it to hook bind API listen on any IP. There is no any background processes neither cost any performance.

How to use

Download release and unzip it on Windows. Run WSLHostPatcher.exe after WSL2 started. This patch needs to running on every time WSL starts, and only the ports listening after running patch will work. You can also do one of the following two things to make it run automatically:

  1. put it in your .profile - see #1.
  2. put it in /etc/wsl.conf (suitable for auto-run services like ssh - runs on boot):
[boot]
command=<path to WSLHostPatcher.exe>

How to restore

wsl --shutdown or Reboot system.

Security Consideration

Listen port on any interfaces may cause some security problems. You are on your own.

Anti-virus software may alert, see discussion.

wslhostpatcher's People

Contributors

czbix avatar ilazycat avatar zeze-zeze avatar zp-zpanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wslhostpatcher's Issues

New version of wsl seems to use wslrelay.exe to take care of network forward

WSLHostPatcher was running fine until this morning. After some digging around I found that it seems my current version of wsl2 is using wslrelay.exe instead of wslhost.exe to take care of port listening on windows side, which I think cause current version of WSLHostPatcher stop working.

I'm on windows 10 22H2,and my wsl2 version is 1.1.60_x64 (at least base on the binary path). Here's a segment of netstat -anob command output related to wsl. Hope this can help fixing the code.

  TCP    [::1]:22               [::]:0                 LISTENING       17584
 [wslrelay.exe]
  TCP    [::1]:80               [::]:0                 LISTENING       17584
 [wslrelay.exe]
  TCP    [::1]:6379             [::]:0                 LISTENING       17584
 [wslrelay.exe]

Suddenly it doesn´t work anymore...

First i would like to say that this was the only thing that helped me to access wsl2 localhost:8080 from mobile...
But now im not using router anymore, only hotspot from my mobile... in theory it should not matter, as outside wsl2 i can open webpack express server running on windows, but not in wsl2... im very tired of this journey!... actually im writing this issue for you to help us, but already installing git to work locally instead wsl2...
Im not sure if the hotspot thing interfered or if it´s just some windows 11 update who knows...

At first stance i´ve tried to stick using only ngrok... but for some reason ngrok doesn´t full reload, i think it reloaded in the past im not sure... (hot false, neither hot true, i use false i prefer full reload)... also the performance of acessing it direcly via localhost seems superior

UDP support

First of all... thanks for this!

Unfortunately only half my issue is solved. It appears UDP doesn't work. Is that expected?

License Request

This project is awesome and could benefit from an open source license. If you have some time, could you select one that makes it easier for contributions? It's entirely possible that Win 11 won't have resolved the network bridging issue, and we'll need a straightforward app like this to continue patching instances.

How to apply a LICENSE file to the repository

No longer works with WSL2 2.0

Hello,

Recently I upgraded my WSL2 to latest stable version, and unfortunately I found that WSLHostPatcher no longer works with latest version.

WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19044.3693

Although there is no error message, no port can be accessed from remote host.

# WSLHostPatcher.exe
Dll path: C:\Portable Softwares\EXE\WSLHostPatch.dll
Found 5 WSL host

Is there any idea to deal with this?

Where is the .exe?

I'm pretty sure it's something very obvious.. but I don't see the executable anywhere.
Do I have to generate it somehow?
Thanks!

Great Tool! 👍

Just wanted to say thank you for this awesome tool. Now I can finally use WSL2 for cross-network server development.

How to put it in .profile?

Hi, thanks for this tool!

I'm not exactly sure how to put it in .profile?
Is WSLHostPatcher.exe executed in Powershell/cmd aka "outside" of WSL2 or inside of WSL2?

UDP sockets

Thanks for the great tool. It works as expected when using a nodejs express server, but when I try to setup a UDP socket in c++ it doesn't seem to work. Is UDP not supported at all with this workaround?

remote request ip become to localhost

hostpatcher will cause the IP address of all network requests sent to WSL to become localhost.

所有来自远程的请求,其ip地址都变成了localhost

Untitled

Not sure if this is possible...

I am trying to use WSLHostPatcher for HomeKit accessory. This utility doesn't work because I need to be able to broadcast Bonjour or CIAO packets from WSL. Is there a way to have this do that or no?

Only listening on 127.0.0.1

Hi! I tried your solution as it seems the cleanest approach, but so far I haven't had any luck. Maybe you have an idea what might be happening.

sshd is running on WSL2 instance and I tried from the windows host and I can do ssh to linux fine

No luck from other machines on my network though, I disabled the firewall on Windows just in case but still the same

This is the output that I get from netstat, shouldn't this be listening on 0.0.0.0:22

netstat -an | grep :22
  TCP    127.0.0.1:22           0.0.0.0:0              LISTENING
  TCP    [::1]:22               [::]:0                 LISTENING

After reading some of the issues, I wasn't sure where to run the patch, windows or wsl, but it seems that doesn't matter I get the same output, although nothing seems to work

Dll path: C:\bin\WSLHostPatch.dll
Found 2 WSL host
Patched 2

wslhostpatcher stopped working

I've been using wslhostpatcher successfully for a while to get access to my locally running Rancher-Desktop from an Domain from outside (only for development purposes).

Setup:

  • Windows 10 Enterprise
  • Rancher Desktop 1.6.2
  • WSL 2 1.0

My workflow was:

  • start Rancher Desktop
  • run wslhostpatcher.exe
  • restart Rancher Desktop

Since the last WSL2 update it stopped working, the applications running in Rancher Desktop are no more available from outside.

Unfortunately it is very uncomfortable without wslhostpatcher to make applications available which are running in the WSL2.

Is there any help? Any new version of wslhostpatcher?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.