shayne / go-wsl2-host

Automatically update your Windows hosts file with the WSL2 VM IP address
1.65k stars 142 forks source link

Everything works fine... Until router port forwarding #23

Open ar065 opened 4 years ago

ar065 commented 4 years ago

Everything seems to work fine up until port forwarding with my router. I ran the same code hosting a websocket server on port 8443, I could easily access it through the port forwarding from my router when I was just running it on windows, however, when running that same code on ubuntu 20.4 with wsl2, I cannot access to the websocket server on port 8443.

rakker91 commented 4 years ago

Hate to say it, but this is what I'd have expected to happen. All this is doing is updating the hosts file on your machine, it's not doing any of the routing itself. Windows uses the hosts file to map host names to ip addresses for local requests to external hosts.

To do what you're expecting to happen, you'd need a router on your windows machine that could accept inbound port requests from port 8443 and then forward them to the wsl instance based on the host lookup. Alternatively, you'd need something that published the wsl VM's IP address to your router and then have the router port forward to that address instead.

These are not the droids you're looking for . . .