Last active
May 6, 2022 00:39
-
-
Save friddle/2833759d7ce6f187d1c57ef2dd08ba38 to your computer and use it in GitHub Desktop.
绑定WSLip和端口
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
echo "wsl port shell start" | |
wsl_ip=$(wsl.exe bash -c "ip addr show eth0 | grep \"inet\b\""|awk '{print $2}'|cut -d/ -f1) | |
echo "wsl ip:${wsl_ip}" | |
echo "port:9001" | |
netsh interface portproxy add v4tov4 listenport=9001 listenaddress=0.0.0.0 connectport=9001 connectaddress=${wsl_ip} | |
netsh advfirewall firewall add rule name="ALLOW TCP PORT 9001" dir=in action=allow protocol=TCP localport=9001 | |
echo "port:9022" | |
netsh interface portproxy add v4tov4 listenport=9022 listenaddress=0.0.0.0 connectport=22 connectaddress=${wsl_ip} | |
netsh advfirewall firewall add rule name="ALLOW TCP PORT 9022" dir=in action=allow protocol=TCP localport=9022 | |
echo "wsl port shell end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment