netsh
,使用
netsh interface portproxy
指令,新增和修改配置信息后,即时生效,而且重启系统后配置信息仍然存在,很是方便。适用于WindowsXP、Windows7,其余的版本尚未试过,支持IPv4和IPv6,可是只支持TCP协议。
以netsh interface portproxy add v4tov4
为例,其语法格式以下:程序员
netsh interface portproxy add v4tov4 [listenport=]<integer>|<servicename>
[connectaddress=]<IPv4 address>|<hostname>
[[connectport=]<integer>|<servicename>]
[[listenaddress=]<IPv4 address>|<hostname>]
[[protocol=]tcp]windows
netsh interface portproxy add v4tov4 listenport=8080 connectaddress=192.168.56.101 connectport=8080
tcp
netsh interface portproxy add v4tov4 listenport=9090 connectaddress=192.168.56.101 connectport=9090
将本地的9090端口的数据转发至192.168.56.101上的9090端口。
netsh interface portproxy show all - 显示全部端口代理参数。
netsh interface portproxy show v4tov4 - 显示 IPv4 代理链接到另外一个 IPv4 端口的参数。
netsh interface portproxy show v4tov6 - 显示 IPv4 代理链接到 IPv6 的参数。
netsh interface portproxy show v6tov4 - 显示 IPv6 代理链接到 IPv4 的参数。
netsh interface portproxy show v6tov6 - 显示 IPv6 代理链接到另外一个 IPv6 端口的参数。spa
netsh interface portproxy show all
代理
netsh interface portproxy set v4tov4 - 更新经过 IPv4 的 IPv4 和代理链接到的侦听项目。
netsh interface portproxy set v4tov6 - 更新经过 IPv6 的 IPv4 和代理链接到的侦听项目。
netsh interface portproxy set v6tov4 - 更新经过 IPv4 的 IPv6 和代理链接到的侦听项目。
netsh interface portproxy set v6tov6 - 更新经过 IPv6 的 IPv6 和代理链接到的侦听项目。code
以netsh interface portproxy set v4tov4
为例,其语法格式以下:blog
netsh interface portproxy set v4tov4 [listenport=]<integer>|<servicename>
[connectaddress=]<IPv4 address>|<hostname>
[[connectport=]<integer>|<servicename>]
[[listenaddress=]<IPv4 address>|<hostname>]
[[protocol=]tcp]ip
参数:
标记 值
listenport - IPv4 侦听端口。
connectaddress - IPv4 链接地址。
connectport - IPv4 链接端口。
listenaddress - IPv4 侦听地址。
protocol - 使用的协议。如今只支持 TCP。
说明: 更新经过 IPv4 的 IPv4 和代理链接到的侦听项目。开发
netsh interface portproxy set v4tov4 listenport=9090 connectaddress=192.168.56.101 connectport=9080
get
将本地9090端口改为转发至192.168.56.101的9080端口中。
以netsh interface portproxy delete v4tov4
为例,其语法格式以下:
netsh interface portproxy delete v4tov4 [listenport=]<integer>|<servicename>
[[listenaddress=]<IPv4 address>|<hostname>]
[[protocol=]tcp]
netsh interface portproxy delete v4tov4 listenport=9090
删除本地端口9090的端口转发配