This is not a design flaw in Windows 11 but intended to make WSL2 less prone to security issues. I would suggest the following alternative if you need access to WSL2 from your LAN or even WAN:
- Establish an autossh connection from your Windows 11 host (WSL2) to a server or machine in your LAN
- Start SSH and autossh on user logon from Windows with the following commands:C:\Users\\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start"
C:\Users\\AppData\Local\Microsoft\WindowsApps\bash.exe -c "autossh -M 0 -f -N -R :localhost: host.domain.tld -p && sleep 1"(note: sleep 1 second is required to give autossh time to drop into background before the shell is terminated)
- Allow /etc/init.d/ssh to be started as root by your Windows login user in WSL (visudo)
- Add the following options in the server's sshd_config to have ssh drop the connection if unresponsive:ClientAliveInterval 60
ClientAliveCountMax 10
With this you can access your WSL2 instance anytime from anywhere. You will need to open the '''' in your firewall if you need WAN access, and you should consider restricting the task in Task Scheduler to run on "AC power" only to preserve battery.