Total Pageviews

Friday 9 February 2018

ngrok/frp的替代品-otunnel

Build

simple build (RECOMMENDED):
$ ./build-by-docker.sh
others:
$ go get -v github.com/ooclab/otunnel
$ export GOPATH=${GOPATH:-~/go}
$ cd $GOPATH/src/github.com/ooclab/otunnel

$ # use any of following commands to build otunnel

$ make                    # normal build
$ make static             # build a static program
$ go build -v             # the go build
$ gox                     # simple cross build, you should install gox first!

Usage

Start a server at a public server ( example.com ):
./otunnel listen -d
Start a client (reverse forward):
./otunnel connect example.com:10000 -d -t r:LOCAL_HOST:LOCAL_PORT::REMOTE_PORT
Now, anyone can access your LOCAL_HOST:LOCAL_PORT by example.com:REMOTE_PORT.

Docker

Run a server:
docker run --rm -it --net=host ooclab/otunnel-amd64 /otunnel listen :10000 -d -s abc123
Run a client:
docker run --rm -it --net=host ooclab/otunnel-amd64 /otunnel connect SERVER_IP:10000 -d -s abc123 -t 'f:127.0.0.1:10022:HOST_IP:HOST_PORT'

Document

Wiki / 手册

Download

Download
For example:
wget http://dl.ooclab.com/otunnel/1.2.3/otunnel_linux_amd64.xz
unxz otunnel_linux_amd64.xz
chmod a+x otunnel_linux_amd64
mv otunnel_linux_amd64 otunnel

Help

Please send issues to github.com/ooclab/otunnel/issues .

Other Projects


  • qtunnel
  • ngrok
  • frp
  • pagekite
from https://github.com/ooclab/otunnel
-------

物尽其用:使用otunnel把64M小内存鸡用作服务中心

64M RAM 的小鸡只能当玩具,没别的用处?其实不是。只要它还有一个公网 IP ,那就可以让你远程访问家里的电脑,或者远程桌面,或者是让你在树莓派上建的站能在公网访问。

什么是 otunnel ?
otunnel 是一个开源的点对点隧道工具。简单地说,它可以把设备的一个本地端口与 VPS 上的一个远程端口相连接。访问 VPS 的远程端口,相当于访问本地端口。

当然,上面说的是反向代理, otunnel 还可以正向工作,把远程端口与本地端口相连接,让访问本地端口相当于访问远程端口。
最简单的实例

我的电脑上的 9927 端口运行有网页服务器 nginx 。但是我处在内网,没有公网 IP ,因此网页也只能在局域网内访问。但是好在我有一个 VPS ,我想把 VPS 的 80 端口与本地的 9927 端口相连接,这样访问 VPS 的 80 端口,就可以在公网访问我局域网内的网站了。
第一步,设置服务器

通过 SSH 连线到 VPS 。下载适用于服务器的 otunnel.
   
# Linux 64位使用:
wget https://dl.ooclab.com/otunnel/1.2.3/otunnel_linux_amd64 && chmod +x otunnel_linux_amd64
# Linux 32位使用:
wget https://dl.ooclab.com/otunnel/1.2.3/otunnel_linux_386 && chmod +x otunnel_linux_386
# Linux ARM架构使用:
wget https://dl.ooclab.com/otunnel/1.2.3/otunnel_linux_arm && chmod +x otunnel_linux_arm


接着运行服务端程序。
   
# Linux 64位使用:
./otunnel_linux_amd64 listen :10000 -s [自定义密钥] >> otunnel.log 2>&1 &
# Linux 32位使用:
./otunnel_linux_386 listen :10000 -s [自定义密钥] >> otunnel.log 2>&1 &
# Linux ARM架构使用:
./otunnel_linux_arm listen :10000 -s [自定义密钥] >> otunnel.log 2>&1 &


第二步,客户端连线
从https://dl.ooclab.com/otunnel/1.2.3/  上下载适合自己系统的程序。打开终端切换到下载的程序所在目录,执行:
./otunnel_*** connect [VPS的IP]:10000 -s [刚才指定的密钥] -t 'r:192.168.1.101:9927::80'

最后一部分的格式:
代理类型 : 本地地址 : 本地端口 : 远程地址 : 远程端口
本实例使用反向代理,本地地址为 192.168.1.101 ,端口为 9927 ,要连接的远程端口为 666 。
享受你的成果

打开浏览器,输入 VPS 的 IP 或绑定的域名,就可以在公网访问你树莓派上的站了。
性能

经我的测试, otunnel 空载的时候占用 RAM 约为 5M 。每个新连接会占用大约 1M 的 RAM ,所以即使是 64M 的小鸡也能带的动。
其他的用途举例:

    映射本地的 3389 端口到 VPS ,可以实现远程桌面连接内网的 Windows 电脑 .
    映射校园网内网部署的代理端口至 VPS ,可实现校外选课

文档
详细说明请参见 otunnel 的文档: https://github.com/ooclab/otunnel/wiki/USAGE.zh_CN

 

 

No comments:

Post a Comment