Obtaining realm
Get the file from the author's github:
amd system:
wget -O realm.tar.gz https://github.com/zhboner/realm/releases/download/v2.4.6/realm-x86_64-unknown-linux-gnu.tar.gz && tar -xvf realm.tar.gz && chmod +x realm
arm system:
wget -O realm.tar.gz https://github.com/zhboner/realm/releases/download/v2.4.6/realm-aarch64-unknown-linux-gnu.tar.gz && tar -xvf realm-aarch64-unknown-linux-gnu.tar.gz && chmod +x realm
Configure global startup
mv realm /usr/local/bin/
Usage of realm
Forwarding information:
Transit VPS and port: 1.1.1.1:1111
Landing VPS and port: 8.8.8.8:8888
1. Normal startup#
- Simple usage:
Execute the command directly on the transit VPS:
./realm -l 0.0.0.0:1111 -r 8.8.8.8:8888
- Using a configuration file:
Create a TOML file:
mkdir /etc/realm/
mkdir /etc/realm/logs/
vim /etc/realm/config.toml
Enter the content in the config.toml file and save it:
[log]
level = "warn"
output = "/etc/realm/logs/realm.log"
[network]
no_tcp = false
use_udp = true
[[endpoints]]
listen = "0.0.0.0:1111"
remote = "8.8.8.8:8888"
Remember to include brackets for IPv6 forwarding, such as: [ipv6]:8888
Start realm using the configuration file:
./realm -c config.toml
- Create a startup service:
Because it is inconvenient to run manually every time, we need to create a service item for Linux to achieve automatic startup of the forwarding channel.
For example, create a service item, first use nano to edit the content of the service item:
vim /etc/systemd/system/realm.service
If your realm main program and configuration file are in the same directory as mine (/root), you can directly use the following content
[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
ExecStart=realm -c /etc/realm/config.toml
[Install]
WantedBy=multi-user.target
Then use ctrl+o to save the file, and then use ctrl+x to exit the editor, and the service file will be generated.
- Enable service configuration startup:
After returning to the /root path via ssh, you can reload the system service and start the realm service:
systemctl daemon-reload
systemctl enable realm && systemctl start realm
If you feel that it has not started, you can stop the service first, and then check the error log status using status
systemctl stop realm && systemctl status realm
If you need to disable realm self-startup and stop the running process of realm, execute the following command:
systemctl stop realm && systemctl disable realm
If your landing server uses a dynamic IP or DDNS service, you can set a scheduled restart of the realm service in the crontab scheduled task:
cronteb -e
Fill in the time and restart the service name:#
realm forwarding example file example