interface
portproxy
端口代理配置
- 显示已配置: netsh interface portproxy show all
# 配置
netsh interface portproxy add v4tov4 listenport=64422 listenaddress=0.0.0.0 connectport=22 connectaddress=172.31.8.8
# 删除
netsh interface portproxy delete v4tov4 listenport=64422 listenaddress=0.0.0.0
- listenport: 本机端口
- listenaddress: 本机
- connectport: wsl 服务端口
- connectaddress: wsl 地址
advfirewall
防火墙配置
启用端口
放行 80 端口
netsh advfirewall firewall add rule name= "Open Port 80" dir=in action=allow protocol=TCP localport=80
删除
netsh advfirewall firewall delete rule name= rule name protocol=tcp localport=80
修改
netsh advfirewall firewall set rule name="ubuntu" new localport=64422
- name: 指定要修改的规则名称
- new: 后面跟随要修改的配置,这里是修改端口
显示已配置
netsh advfirewall firewall show rule name=all