wsl2 mirrored mode is not experimental now, but some tutorial still use the old style.
WSL 版本: 2.2.4.0
内核版本: 5.15.153.1-2
WSLg 版本: 1.0.61
MSRDC 版本: 1.2.5326
Direct3D 版本: 1.611.1-81528511
DXCore 版本: 10.0.26091.1-240325-1447.ge-release
Windows 版本: 10.0.22631.3880
First, the kernel should be 2.2.4. Be careful about the upgrade, plz make backup. I failed in one machine, and reinstalled the kernel.
Then, set the ~/.wslconfig
in win11:
[wsl2]
networkingMode=mirrored # 开启镜像网络
dnsTunneling=true # 开启 DNS Tunneling
firewall=true # 开启 Windows 防火墙
autoProxy=true # 开启自动同步代理
[experimental]
hostAddressLoopback=true
wsl2 shutdown and start again.
And v2ray socks port in windows, wsl can access it too! Default addr is 127.0.0.1:10808.
To make wsl2 accessiable in LAN, binding 0.0.0.0 is not working for me. So bind 192.168.x.x. In wsl2:
python3 -m http.server --bind 192.168.x.x
In win11 powershell or web browser, you can access it.
To make LAN access it, let it pass the firewall:
sudo New-NetFirewallRule -DisplayName "允许 HTTP8000" -Direction Inbound -LocalPort 8000 -Protocol TCP -Action Allow
Get-NetFirewallRule -DisplayName "允许 HTTP8000"
# delete
sudo Remove-NetFirewallRule -DisplayName "允许 HTTP8000"