Preface
Because some services and software cannot run in the windows environment, they need to use the linux environment. Compared with wsl, Docker has a loss in convenience and performance (Docker itself uses wsl2), so for me it is more convenient to use wsl2. Convenience.
Instructions
# 查看所有端口代理列表
netsh interface portproxy show all
# 添加端口映射的关联
# listenport 配置宿主机需要映射端口号, listenaddress 配置宿主机的需要映射的ip, 往往就为 0.0.0.0
# connectport 配置 wsl2 的端口号(服务), connectaddress 为 wsl2 的IP地址
netsh interface portproxy add v4tov4 listenport=9504 listenaddress=0.0.0.0 connectport=9504 connectaddress=192.168.21.132
If the wsl2 ip address changes during the period, you can delete and reconfigure it as shown in the following code
netsh interface portproxy delete v4tov4 listenport=9504 listenaddress=0.0.0.0