netsh功能强大,今天只用到它的interface的portproxy的相关功能。
首先,netsh有两种使用方式,一种是完整的命令方式,如果直接在命令行下执行
netsh interface portproxy show all
另外一种是提示符方式,在命令行输入netsh进入netsh>提示符,再输入interface回车,进入netsh interface>提示符;再输入portproxy回车,进入netsh interface portproxy>
如果手工操作,建议使用第二种方式,可以减少字符输入;如果是做成脚本,就使用第一种方式,粗暴。
添加端口转发,譬如,要将本地8888端口转发给到172.18.188.210:
netsh interface portproxy add v4tov4 listenport=8888 connectaddress=172.18.188.210查看当前转发情况
netsh interface portproxy show all
删除转发(按监听端口):
netsh interface portproxy delete v4tov4 listenport=8888
