As I have VPN run on windows11, when I launch the WSL2, always prompt the tip about the autoproxy not working for my VPN.
Then I did the configuration for WSL which to put the .wslconfig in to my user root with below content:
[experimental]
autoMemoryReclaim=gradual # gradual | dropcache | disabled
networkingMode=mirrored
dnsTunneling=true
firewall=false
autoProxy=true
Above setting let the WSL2 running on mirrored networking mode with share same ip address with the host windows.
But problem is I can not access the go api which run in the WSL2 Ubuntu via LAN. To resolve this issue, the information in this page is helpful:
https://github.com/microsoft/WSL/issues/10714
Run below command
New-NetFirewallHyperVRule -DisplayName “allow port 3001 inbound” -Direction Inbound -LocalPorts 3001 -Action Allow
on the windows host to permit the port you want to visit from LAN.