Skip to content

USAGE.zh_CN

gwind edited this page Feb 12, 2017 · 3 revisions

otunnel 用法

前提:

  1. 假设 server 的地址为 example.com
  2. 从 client 能连接 server (client 与 server 无需在同一个网络)

注意 otunnel 程序可以作为 server 和 client 两种角色(运行参数不同)

快速上手

server

./otunnel listen :10000 -s longlongsecret

client

反向代理

举例:将 client 可以访问的 192.168.1.3:22 映射到 server 上的 10022 端口:

./otunnel connect example.com:10000 \
    -s longlongsecret -t 'r:192.168.1.3:22::10022'

现在访问 example.com:10022 即等于访问了 client 内网的 192.168.1.3:22

正向代理

举例:假设 example.com 的 127.0.0.1:3128 服务(你懂得),在 client 运行:

./otunnel connect example.com:10000 \
    -s longlonglongsecret -t 'f::20080:127.0.0.1:3128'

现在 client 的 20080 端口, 等于访问 example.com 上的 127.0.0.1:3128

程序用法

-t 格式

包含多个字段信息,以 : 隔开(为空的字段也不能省略:)。

代理类型:本地地址:本地端口:远程地址:远程端口
字段 含义
代理类型 r 表示反向代理; f 表示正向代理
本地地址 IP或域名
本地端口 整数
远程地址 IP或域名
远程端口 整数

注意

  1. 本地地址远程地址 如果为空,表示所有网口
  2. otunnel 命令行可以包含多个 -t 选项,同时指定多条隧道规则
Clone this wiki locally