Enable LAN Access for WSL 2
I use WSL 2 to run LLM AI models on my laptop, which is very convenient when you need to keep Windows as your main OS.
However, when you want to access a network service running on a WSL system from the LAN, you have to do some configuration.
Since the WSL OS network runs under NAT, you need to set up a port proxy on the host Windows OS.
Use the following command to get the WSL system IP address:
wsl hostname -I |
Then, run the following command to apply the port proxy (assuming the WSL system IP is 172.22.38.136).
netsh interface portproxy add v4tov4 listenport=18863 listenaddress=0.0.0.0 connectport=18863 connectaddress=172.22.38.136 |
Don’t forget to set both firewall rules on Windows and WSL.
