Realm转发

Realm转发

github项目

1
https://github.com/zhboner/realm

特点

  • 支持DDNS 只要传入一个域名,那么就能自动后台更新解析。

  • 支持DDNS 只要传入一个域名,那么就能自动后台更新解析。

  • 高效,低消耗 依托于Rust语言,Realm保证内存安全。另外,相较于采用Go语言编写的Brook和gost,Realm执行速度更快,资源占用更低,非常适合在低配置的主机上使用。

  • 简单 相较于使用iptables动辄几条复杂的命令,Realm仅需一条命令就能启动,保证了部署的方便。

  • UDP + TCP 无需额外的工作,Realm就能同时转发UDP和TCP。

安装Realm

1
2
3
4
mkdir /etc/realm && cd /etc/realm 
wget https://github.com/zhboner/realm/releases/download/v2.3.4/realm-x86_64-unknown-linux-musl.tar.gz

tar xf realm-x86_64-unknown-linux-musl.tar.gz

直接运行

1
2
3
4
# -l 指定监听的本机地址和端口,地址可以省略,但必须指定端口。不指定地址的话会使用默认的 127.0.0.1 地址。
# -r 指定转发的目的地址和端口,均不能省略。
/etc/realm/realm -l 中转机IP:端口 -r 落地机IP或域名:端口
示列: ./realm -l 0.0.0.0:9004 -r 44.92.103.211:33189

配置文件

https://github.com/zhboner/realm/blob/master/examples

Realm支持json和toml两种格式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
vim /etc/realm/config.toml


# 最简配置
[[endpoints]]
listen = "0.0.0.0:5000"
remote = "1.2.3.4:443"

[[endpoints]]
listen = "0.0.0.0:6000"
remote = "5.6.7.8:443"

# 常用配置
[network]
use_udp = true
zero_copy = true

[[endpoints]]
listen = "0.0.0.0:5000"
remote = "1.2.3.4:443"

[[endpoints]]
listen = "0.0.0.0:6000"
remote = "5.6.7.8:443"

# 完整配置
[dns]
mode = "ipv4_only"
protocol = "tcp_and_udp"
nameservers = ["1.1.1.1:53", "1.0.0.1:53"]
min_ttl = 600
max_ttl = 3600
cache_size = 256

[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:5000"
remote = "1.2.3.4:443"

[[endpoints]]
listen = "0.0.0.0:6000"
remote = "5.6.7.8:443"

json格式示列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
vim /etc/realm/config.json

{
"endpoints": [
{
"listen": "0.0.0.0:9001",
"remote": "6.164.153.76:9000"
},
{
"listen": "0.0.0.0:9002",
"remote": "13.219.30.20:9000"
},
{
"listen": "0.0.0.0:9003",
"remote": "15.238.251.170:9000"
},
{
"listen": "0.0.0.0:9004",
"remote": "13.219.30.115:9000"
},
{
"listen": "0.0.0.0:10001",
"remote": "6.164.153.67:9000"
}
]
}

#注意大括号}结尾不能有逗号[,] ,否则会导致启动不了服务。

设置系统开机启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vim /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.toml

[Install]
WantedBy=multi-user.target

启动

1
2
3
4
systemctl daemon-reload
systemctl enable realm
systemctl restart realm
systemctl status realm

Realm一键脚本 https://github.com/seal0207/EasyRealM

1
wget -N --no-check-certificate https://git.io/realm.sh && chmod +x realm.sh && ./realm.sh

评论


:D 一言句子获取中...

加载中,最新评论有1分钟缓存...