Files
vnt/vn-link-cli/README.md
T
2024-06-15 21:03:41 +08:00

62 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 端口映射模式
## 一、特点
1. 不需要tap/tun虚拟网卡
2. 不需要管理员/root权限
3. 不改变本地路由
4. 使用端口映射来访问目标服务
## 二、作用
和vnt互补,能简单快速构建网络,外部依赖更少
## 三、使用方式
和vnt的使用方式一样,只是多了"--vnt-mapping"这个参数
### vn-link作为被访问端,不需要额外配置vnt-mapping
### vn-link访问vnt或者vn-link,需要加vnt-mapping
例如:
设备A 运行vnt(虚拟IP 10.26.0.A),设备B 运行vn-link(虚拟IP 10.26.0.B)。
如果要用B访问A上的tcp 80端口,则在设备B上需要加--vnt-mapping "tcp:port1-10.26.0.A:80"
这个参数的作用是将B上的***本地端口port1***转发到设备A的地址10.26.0.A:
80,此时在设备B上可以访问本地port1端口从而间接访问10.26.0.A:80
## 四、vn-link的子网代理
vn-link也支持点对网参数。 还是接着上面的例子
假设 设备C在设备A的子网下,C的子网IP为192.168.1.CA的子网IP为192.168.1.A,要在设备B上访问C
则在B上加这些参数
- --vnt-mapping "tcp:port2-192.168.1.C:80" (将本地port2端口映射到C的80端口)
- -i 192.168.1.0/24,10.26.0.A (将目标192.168.1.0/24的数据发送到10.26.0.A,也就是A节点)
在A上加参数
- -o 0.0.0.0/0 (允许所有流量转发)
***再次说明,vn-link作为被访问端时和vnt使用方式一致,vn-link作为访问端时需要加--vnt-mapping映射端口***
***vn-link是基于端口映射的使用模式,不会改变本地路由***
## 五、参数介绍
--vnt-mapping支持udp/tcp,例如 --vnt-mapping "tcp:port1-remoteIp:remotePort"
- 第一部分为协议,支持使用udp/tcp
- 第二部分是本地端口,注意不要和本地服务的端口冲突
- 第三部分是目标机器的地址,一般是目标虚拟IP地址,如果配置了点对网参数(-i和-o)则也可以是目标子网地址