核心命令 netsh, 此工具在win10下,支持大量网络相关配置,可参考:netsh官方文档
在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
在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 - 丢弃在脱机模式下所做的更改。
- add - 在项目列表上添加一个配置项目。
- advfirewall - 更改到 `netsh advfirewall' 上下文。
- alias - 添加一个别名
- branchcache - 更改到 `netsh branchcache' 上下文。
- bridge - 更改到 `netsh bridge' 上下文。
- bye - 退出程序。
- commit - 提交在脱机模式中所做的更改。
- delete - 在项目列表上删除一个配置项目。
- dhcpclient - 更改到 `netsh dhcpclient' 上下文。
- dnsclient - 更改到 `netsh dnsclient' 上下文。
- dump - 显示一个配置脚本。
- exec - 运行一个脚本文件。
- exit - 退出程序。
- firewall - 更改到 `netsh firewall' 上下文。
- help - 显示命令列表。
- http - 更改到 `netsh http' 上下文。
- interface - 更改到 `netsh interface' 上下文。
- ipsec - 更改到 `netsh ipsec' 上下文。
- lan - 更改到 `netsh lan' 上下文。