1. 写在前面
核心命令 netsh, 此工具在win10下,支持大量网络相关配置,可参考:netsh官方文档
2. 命令行批模式
在CMD或PowerShell中,执行以下命令, 可能会提示需要管理员权限执行
# 添加转发规则,本地3306端口转192.168.1.168:3306
netsh interface portproxy add v4tov4 listenport=3306 connectaddress=192.168.1.168 connectport=3306
# 删除规则
netsh interface portproxy delete v4tov4 listenport=3306
# 查看规则
netsh interface portproxy show all
3. 命令行交互模式
在CMD或PowerShell中,执行以下命令, 可能会提示需要管理员权限执行
PS C:\Users\Administrator> netsh
netsh>interface
netsh interface>portproxy
netsh interface portproxy>add v4tov4 listenport=3306 connectaddress=192.168.1.168 connectport=3306
netsh interface portproxy>show all
netsh interface portproxy>delete v4tov4 listenport=3306
# 回退到上一级
netsh interface portproxy>..
netsh interface>..
# 显示帮助信息
netsh>?
下列指令有效:
此上下文中的命令:
.. - 移到上一层上下文级。
? - 显示命令列表。
abort - 丢弃在脱机模式下所