当前位置: > Linux教程 > Linux学习 >

Linux下TCP中转 端口转发 tcptunnel

时间:2015-12-08 17:16来源:linux.it.net.cn 作者:IT
解决方法说来并不复杂,你需要一台在国内的 VPS、一台在境外的 VPS,通过国内 VPS 中转境外 VPS 上架设的代理,换言之用国内“跳板”绕开你本地网络的出国瓶颈。

具体实现的方法有很多,比如 socat / HAProxy 等等。Yculer 偏向于 tcptunnel,一个用 c 语言写的 TCP 隧道程序(端口转发),性能稳定,占用资源少,支持 buffer、fork和长连接。

官方地址: https://github.com/vakuum/tcptunnel

1. 安装 tcptunnel:

cd /usr/local/src
git clone https://github.com/vakuum/tcptunnel.git
cd tcptunnel
./configure
make && make install

2. 假设国内 vps 的端口为 1080,境外 vps 的 ip 地址为 106.187.96.1,端口为 1081,运行 tcptunnel:

/usr/local/src/tcptunnel/tcptunnel --local-port=1080 --remote-port=1081 --remote-host=106.187.96.1 --fork --buffer-size=8192 --stay-alive

这样你访问国内 vps 的 1080 端口时,所有的 tcp 流量都会转发到 106.187.96.1 的 1081 端口。

后面的内容应该不需要指点了吧,在 106.187.96.1 的 1081 端口上架设你习惯使用的代理,然后通过国内 vps 的 1080 端口连接它。
(责任编辑:IT)
------分隔线----------------------------