Created
April 17, 2022 12:47
-
-
Save Val-istar-Guo/08e86d2c54b2af7964c789efd4a1649a to your computer and use it in GitHub Desktop.
将WSL的端口与电脑本机端口绑定
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: 删除之前的接口代理 | |
netsh interface portproxy reset | |
:: 查询WSL的IP地址 | |
for /f %%i in ('wsl hostname -I') do ( | |
SET wsl_ip=%%i | |
) | |
:: 将本地端口与WSL的IP地址绑定 | |
SET wsl_port=3000 | |
netsh interface portproxy add v4tov4 listenport=%wsl_port% listenaddress=0.0.0.0 connectport=%wsl_port% connectaddress=%wsl_ip% | |
SET wsl_port=8080 | |
netsh interface portproxy add v4tov4 listenport=%wsl_port% listenaddress=0.0.0.0 connectport=%wsl_port% connectaddress=%wsl_ip% | |
:: 查看绑定结果 | |
netsh interface portproxy show all | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Windows研发时需要使用内网其他机器访问启动的应用程序,需要将WSL的端口和电脑的端口绑定后,才能够正常访问