今天买了个鸡仔云国内ipv6小鸡儿,ipv4不通海外,但ipv6可以,因此想到可以通过realm来中转海外vps实现优化连接的作用(前提是海外vps也有ipv6)

假设国内小鸡ipv4:1.2.3.4 端口:12345
海外小鸡ipv6:[1111:2222:3333:4444:5555:6666:7777:8888] 端口:8080

通过ssh连上鸡仔云vps
1. 下载realm

wget https://pan.bobqu.cyou/Code/realm
chmod +x realm

2.编辑realm配置

cat > /root/config.toml <<EOF
[[endpoints]]
listen = "0.0.0.0:8000"
remote = "1.1.1.1:443"

[[endpoints]]
listen = "0.0.0.0:12345"
remote = "[1111:2222:3333:4444:5555:6666:7777:8888]:8080"

[network]
no_tcp = false
use_udp = true
EOF

3.编辑启动服务

cat > /etc/systemd/system/realm.service <<EOF
[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=/root
ExecStart=/root/realm -c /root/config.toml

[Install]
WantedBy=multi-user.target
EOF

4.启动realm

systemctl daemon-reload
systemctl enable realm
systemctl restart realm
systemctl status realm

Ok,这个时候你就可以通过连接1.2.3.4:12345 实现中转海外vps的目的了

注:

  1. realm可以同时中转多个vps,本例中还同时通过1.2.3.4:8000 中转了这个海外ipv4地址和端口 1.1.1.1:443
  2. 另外如果你海外vps用docker版的xrayr或v2等等,需要将Docker网络模式设置为host,这样的话才能使用ipv6,xrayr还需要将DNS设置为useip

参考来源:nodeseek论坛

Last modification:July 3, 2024
If you think my article is useful to you, please feel free to appreciate