keyfil/教程/工具/20250507-Windows实现流量转发.md

66 lines
1.6 KiB
Markdown
Raw Normal View History

<!-- Space: qifu -->
<!-- Parent: 后端技术&知识&规范 -->
<!-- Parent: 技术方案 -->
<!-- Parent: 基建 -->
<!-- Parent: 04-使用教程 -->
<!-- Title: 20250507-Windows实现流量转发 -->
<!-- Macro: :anchor\((.*)\):
Template: ac:anchor
Anchor: ${1} -->
<!-- Macro: \!\[.*\]\((.+)\)\<\!\-\- width=(.*) \-\-\>
Template: ac:image
Url: ${1}
Width: ${2} -->
<!-- Macro: \<\!\-\- :toc: \-\-\>
Template: ac:toc
Printable: 'false'
MinLevel: 2
MaxLevel: 4 -->
<!-- Include: 杂项/声明文件.md -->
<!-- :toc: -->
# Windows实现流量转发
## 解决问题
- 可以将本机流量转发到同事电脑或这虚拟机内
- 解决三方对接只能配置一个回调问题
## 注意
- 流量转发会占用端口,所以需要先停止本地服务
- 本地服务启动后开启流量转发,配置成功但是不会生效
## 快速使用
### 打开命令提示符
- 以管理员身份打开命令提示符。
### 查看当前端口转发规则
```shell
netsh interface portproxy show all
```
### 添加转发规则
```shell
netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=8933 connectaddress=10.168.1.183 connectport=8933
```
- listenaddress=本地IP地址
- listenport=本地端口
- connectaddress=目标IP地址
- connectport=目标端口
### 清除单个转发
```shell
netsh interface portproxy delete v4tov4 listenaddress=127.0.0.1 listenport=8933
```
### 清除所有转发
```shell
netsh interface portproxy reset
```
## 参考文档
- https://www.cnblogs.com/amnotgcs/p/18291025
- https://www.cnblogs.com/sttchengfei/p/13209761.html