For Windows 11 there was an update to WSL2 in September 2023 with (hopefully) a fix for this issue. Create a file %UserProfile%\.wslconfig
with the content below, and then restart wsl. Run wsl.exe --shutdown
. I also had to restart my computer but I am not sure if that is always necessary.
[experimental][wsl2]
networkingMode=mirrored
dnsTunneling=true
After changing these settings restart WSL (i.e. run wsl --shutdown
; just closing the running distribution isn't sufficient).
Update 2024-02-27
These settings should now fall under [wsl2]
instead of [experimental]
. Related docs
References: