rein 多平台支持的超便携端口转发工具

rein 是一个类似 rinetd 的端口转发工具,也可以用于内外网端口转发等多种应用场景。

程序使用了 golang 开发,部署比 rinetd 更便携,下载开箱即用。

rein 的 github 地址:https://github.com/firstboot/rein

由于 rein 使用了 golang 开发,对系统环境依赖少,在一个平台上就能一次交叉编译出多个平台的可执行程序,项目主页已经提供了各平台(windows/linux/mac)可执行版本下载。

下面来介绍下 rein 的使用方法:

  • CentOS/RHEL/Ubuntu 平台

已经编译好的版本下载地址: https://github.com/firstboot/rein/releases

下载 rein-amd64-linux-x.x.x.zip

如果您的 Linux 具备公网下载功能,可以直接通过下面的命令进行下载使用,如果不能访问外网,则可以先下载,然后存放到 Linux 服务器上。

cd ~
wget http://note.youdao.com/yws/public/resource/b1e1ad270ba1b1af97ebdf3e2c8b7403/xmlnote/A60A15B111264423B0CA2075886CA875/27280 -O rein.zip
# 需要安装 unzip 
unzip rein.zip
mv rein-*-linux rein
chmod +x rein
./rein -e > rein.json

修改配置文件为下面的内容,配置了两条转发规则:

{
    "upstream": [
        {"source": "0.0.0.0:18309", "target": "192.168.10.18:3309"},
        {"source": "0.0.0.0:19309", "target": "192.168.10.19:3309"}
    ]
}

修改配置文件后启动程序(或关闭程序):

# 修改配置文件 rein.json 后启动
./rein -c rein.json
# 也可以使用后台启动
nohup ./rein -c rein.json > /dev/null &
# 关闭程序
ps -ef | grep rein | awk '{print $2}'|xargs kill -9
  • Mac OS 平台

Mac OS平台64 位1.0.4版本下载

  • Windows 平台

使用您的浏览器下载 https://github.com/firstboot/rein/releases

Windows平台64 位1.0.4版本下载

rein-amd64-windows-x.x.x.zip并解压它。

使用下面的命令生成并修改 rein.json 配置文件

# 解压后先改名
ren rein-1.0.3-amd64-win.exe rein.exe

# generate default conf 'rein.json'
# 使用 cmd 时
./rein.exe -e > rein.json

# 使用 powershell 时
./rein.exe -e | out-file -encoding ascii rein.json

生成的默认配置文件如下:

{
    "upstream": [
        {"source": "0.0.0.0:8150", "target": "127.0.0.1:9991"}
    ],
    "fileshare": [
        {"port": "9991", "path": "."}
    ]
}

根据您的需要进行修改配置文件后,运行:

./rein.exe -c rein.json

猜你喜欢

转载自www.cnblogs.com/gleaners/p/11497148.html