netnr / netsh
2019-03-29 14:23
windows使用netsh命令实现端口转发
  netsh shell
# 安装IPv6,XP或更低版本要安装,安装后不需要启用,win7及以上不需要
netsh interface ipv6 install

# 添加端口转发 192.168.1.2:1433 => 192.168.1.3:1433
netsh interface portproxy add v4tov4 listenaddress=192.168.1.2 listenport=1433 connectaddress=192.168.1.3 connectport=1433

# 添加端口转发 *:1433 => 192.168.1.3:1433 不设置listenaddress
netsh interface portproxy add v4tov4 listenport=1433 connectaddress=192.168.1.3 connectport=1433

# 删除端口转发 192.168.1.2:1433
netsh interface portproxy delete v4tov4 listenaddress=192.168.1.2 listenport=1433

# 查询端口转发列表
netsh interface portproxy show all
ˆ