简介

Github地址:https://github.com/zhboner/realm

一款高性能的流量转发工具,支持转发DDnS域名,并且使用rust语言,消耗少 ,资源占用低。个人认为是目前市面上开源程序中综合表现最优秀的。

使用

1.安装Realm

访问Github Release页面,下载最新版程序包

mkdir -p /etc/realm
cd /etc/realm
wget https://github.com/zhboner/realm/releases/download/v2.6.0/realm-x86_64-unknown-linux-gnu.tar.gz
tar -zxvf realm-x86_64-unknown-linux-gnu.tar.gz
chmod +x realm

2.编辑配置文件

配置文件的详细格式和写法可以查看Github页面

这里以一个json文件为例,展示最基础的TCP/UDP直接转发

{
  "log": {
  	"level": "warn"
  },
  "dns": {
    "mode": "ipv4_and_ipv6",
    "protocol": "tcp_and_udp",
    "min_ttl": 0,
    "max_ttl": 60,
    "cache_size": 5
  },
  "network": {
    "use_udp": true,
    "zero_copy": true,
    "fast_open": true,
    "tcp_timeout": 300,
    "udp_timeout": 30,
    "send_proxy": false,
    "send_proxy_version": 2,
    "accept_proxy": false,
    "accept_proxy_timeout": 5
  },
    "endpoints": [
   {
	"listen": "0.0.0.0:12345",
	"remote": "1.1.1.1:12345"
   },
    {
      "listen": "0.0.0.0:40000",
      "remote": "127.0.0.1:50000",
      "remote_transport": "ws;host=zhongzhuan.top;path=/acd"
    },
    {
      "listen": "0.0.0.0:50000",
      "remote": "127.0.0.1:51000",
      "listen_transport": "ws;host=luodi.host;path=/acd"
    }
    ]
}

测试运行

./realm -c config.json

3.设置系统开机启动

vi /etc/systemd/system/realm.service
[Unit]
Description=realm
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
 
[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
DynamicUser=true
WorkingDirectory=/etc/realm
ExecStart=/etc/realm/realm -c /etc/realm/config.json
 
[Install]
WantedBy=multi-user.target
systemctl daemon-reload #重载systemed
systemctl enable realm #设置realm开机启动
systemctl start realm #启动realm
systemctl status realm #查看realm日志

注意!尽量不要使用github上某一键脚本,一是那个脚本已经很久没有维护了,版本过于落后;二是那个脚本闭源了,有不小的风险。(一键脚本闭源的真没见几个)