This gist describes what needs to be done so a server running inside a WSL context can be accessed by devices on the network of the host device.
It's quite likely that the commands needed to be run will require admin rights, so you will need to have been given at least Local Admin privileges on your machine and then run Powershell as Administrator.
In order for other devices on you local network to find the server on your linux subsystem, you need to set up port forwarding so requests made to your host machine will be passed to the linux vm. The WSL instance will have its own IP which you can get by running wsl hostname -I
.
Then use forward-port-to-wsl2.ps1 <port_to_forward> -guestIP <wsl_ip>
, where port_to_forward
is the port you want to pass-through and wsl_ip
is the IP found for your WSL instance.
You also need to explicitly set your Windows firewall to allow the ports used by your WSL servers to be exposed. To do this run firewall-enable-port.ps1 <port_to_enable>
.
If you want to confirm that you have enabled this port in the firewall you can run Get-NetFirewallRule -Direction Inbound -Enabled True
.