一个 linux 子系统,只能从本机 windows 上通过 localhost 访问可太艹了。要经过一系列复杂的骚操作才能局域网下访问到 wsl 的特定端口。追了这个 issue 两年 https://github.com/microsoft/WSL/issues/4150 现在微软终于在 preview 版本(store 里提供)把这个问题解决了,具体看这一个 comment: https://github.com/microsoft/WSL/issues/4150#issuecomment-1018524753
需要先给 hyper-v 配置 external switch ,注意如果你的网卡是 intel ax200 或者 ax201 ,添加 external switch 会失败,解决办法: https://pomeroy.me/2020/08/hyper-v-virtual-switch-creation-woes/#comment-411452