GoForum🌐 V2EX

wsl2 开启 mirror 模式, 局域网外部设备无法通过网络访问 wsl2 中开启的服务

chaleaochexist · 2026-01-22 11:37 · 0 次点赞 · 4 条回复
  1. wsl2 中开启服务 -h 0.0.0.0
  2. wsl2 可以通过 10.xx 网络访问, 也可以通过 127.xx 访问
  3. windows 宿主机可以通过 127.xx 访问, 但是无法通过 10.xx 访问
  4. 如果这个服务在 windows 上开启, 一切正常.
  5. 和 clash 有关系吗? 不过我试过, 即使 clash 退了也白扯.
[wsl2]
memory=10GB 
processors=4
swap=16GB
pageReporting=true
localhostforwarding=true
networkingMode=mirrored
nestedVirtualization=false
debugConsole=false
dnsTunneling=true
firewall=true
autoProxy=true #强制 WSL 使用 Windows 的 HTTP 代理信息

[boot]
systemd=true

[experimental]
autoMemoryReclaim=gradual # 检测到空闲 CPU 使用率后自动释放缓存内存。设置 gradual 为缓慢释放,设置 dropcache 为立即释放缓存内存。
sparseVhd=true

4 条回复
jimages · 2026-01-22 11:42
#1

你需要设置 windows 设置端口转发 在 windows 上设置,命令如下

netsh interface portproxy add v4tov4 listenport=443 listenaddress=0.0.0.0 connectport=443 connectaddress=(wsl hostname -I)

chaleaochexist · 2026-01-22 11:42
#2

@jimages 您的意思是说 mirrord 模式也需要端口转发是吗?

chaleaochexist · 2026-01-22 11:42
#3

@jimages 试过了 不好用

Alias4ck · 2026-01-22 11:47
#4
添加回复
你还需要 登录 后发表回复

登录后可发帖和回复

登录 注册
主题信息
作者: chaleaochexist
发布: 2026-01-22
点赞: 0
回复: 0