How can you access WSL 2 distribution from your LAN?
Experience Level: Junior
Tags: WSL
Answer
In WSL 1 distribution, the applications run in WSL could be accessed on your LAN out of the box.
In WSL 2, the virtualized ethernet adapter has its own IP address, so to access an app in WSL 2 from Windows, you need to configure the proxy mapping:
netsh interface portproxy add v4tov4 listenport=1433 listenaddress=0.0.0.0 connectport=1433 connectaddress=192.168.224.1
The connectaddress is the IP of the WSL machine.
Related WSL job interview questions
How do you install a WSL distro to a different drive?
WSL JuniorHow can you duplicate a WSL distro?
WSL JuniorHow can you allow a Git in WSL use your Windows Git credentials?
WSL JuniorHow do you copy output of commands in WSL to clipboard?
WSL JuniorHow can you do a backup of your WSL distro?
WSL Junior