返回帮助中心

Realm Port Forwarding

Advanced

Use Realm with WarpTok for flexible port forwarding setups.

最后更新:2024-01-13

What is Realm

About Realm

Realm is a lightweight port-forwarding tool supporting TCP/UDP. It can forward local traffic to WarpTok entry addresses for flexible network architectures.

Use cases

  1. Manage multiple forwarding rules on a local server
  2. Preprocess or monitor traffic
  3. Deploy forwarding nodes inside a private network
  4. Customize forwarding logic

Install Realm

Linux

# Download the latest release
wget https://github.com/zhboner/realm/releases/download/v2.5.4/realm-x86_64-unknown-linux-gnu.tar.gz

# Extract
tar -xzf realm-x86_64-unknown-linux-gnu.tar.gz

# Move to PATH
sudo mv realm /usr/local/bin/

# Verify
realm --version

Windows

  1. Open the GitHub Releases page
  2. Download realm-x86_64-pc-windows-msvc.zip
  3. Extract to a folder (e.g. C:\realm)
  4. Add the folder to your PATH
  5. Open Command Prompt and run realm --version

macOS

# Install via Homebrew
brew install realm

# Or download manually
wget https://github.com/zhboner/realm/releases/download/v2.5.4/realm-x86_64-apple-darwin.tar.gz
tar -xzf realm-x86_64-apple-darwin.tar.gz
sudo mv realm /usr/local/bin/

Basic configuration

Create a config file

Create a realm config file config.toml

# config.toml
[network]
no_tcp = false
use_udp = true

[[endpoints]]
listen = "0.0.0.0:8080"
remote = "203.0.113.45:1935"

# listen: local bind address and port
# remote: WarpTok entry IP and port

Configuration notes

  1. listen: local bind IP and port
  2. - 0.0.0.0 means listen on all interfaces
  3. - You can specify a specific IP like 192.168.1.100
  4. remote: forward target
  5. - Use the WarpTok entry IP and port
  6. - Available in the WarpTok console
  7. no_tcp: disable TCP (default false)
  8. use_udp: enable UDP (default false)

Using with WarpTok

Architecture

Typical three‑layer forwarding

  1. App/Client → Local Realm → WarpTok Entry → Target Server
  2. Example (TikTok Live):
  3. OBS (streaming software)
  4. ↓ stream to local
  5. 127.0.0.1:8080 (Realm listen)
  6. ↓ forward to WarpTok
  7. 203.0.113.45:1935 (WarpTok entry)
  8. ↓ WarpTok forward
  9. live.tiktok.com:1935 (TikTok server)

Setup steps

  1. 1. Configure target address in WarpTok console
  2. - Target IP: live.tiktok.com
  3. - Target port: 1935
  4. 2. Record WarpTok entry address
  5. - Entry IP: e.g. 203.0.113.45
  6. - Entry port: e.g. 1935
  7. 3. Create Realm config
  8. - listen: 0.0.0.0:8080
  9. - remote: 203.0.113.45:1935
  10. 4. Configure OBS
  11. - Server: rtmp://127.0.0.1:8080/live

Advanced configuration

Multi‑port forwarding

Forward multiple ports at once

# config.toml
[network]
no_tcp = false
use_udp = true

# Rule 1: RTMP streaming
[[endpoints]]
listen = "0.0.0.0:8080"
remote = "203.0.113.45:1935"

# Rule 2: HTTP API
[[endpoints]]
listen = "0.0.0.0:8081"
remote = "203.0.113.46:80"

# Rule 3: WebSocket
[[endpoints]]
listen = "0.0.0.0:8082"
remote = "203.0.113.47:443"

Load balancing

Use multiple WarpTok entries for load balancing

[[endpoints]]
listen = "0.0.0.0:8080"
remote = "203.0.113.45:1935"

[[endpoints]]
listen = "0.0.0.0:8080"
remote = "203.0.113.46:1935"

# Realm will balance traffic between the two remote addresses

Enable logging

# config.toml
[log]
level = "info"
output = "/var/log/realm.log"

# level values: trace, debug, info, warn, error
# output specifies log file path

Run Realm

Run in foreground (testing)

# Linux/macOS
realm -c config.toml

# Windows
realm.exe -c config.toml

# If you see "Realm is running..." the service started

Run in background (production)

Use systemd (Linux)

# 1. Create systemd unit
sudo nano /etc/systemd/system/realm.service

# 2. Add the following:
[Unit]
Description=Realm Port Forwarding
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/realm -c /etc/realm/config.toml
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

# 3. Start service
sudo systemctl daemon-reload
sudo systemctl start realm
sudo systemctl enable realm  # start on boot

# 4. Check status
sudo systemctl status realm

# 5. View logs
sudo journalctl -u realm -f

Run in background on Windows

  1. Method 1: Use NSSM (recommended)
  2. - Download NSSM: nssm.cc
  3. - Run: nssm install Realm
  4. - Path: C:\realm\realm.exe
  5. - Arguments: -c C:\realm\config.toml
  6. - Click Install service
  7. Method 2: Use Task Scheduler
  8. - Open Task Scheduler
  9. - Create a basic task
  10. - Trigger: At startup
  11. - Action: start realm.exe

Monitoring and maintenance

Check service status

# Linux (systemd)
sudo systemctl status realm

# View logs
sudo journalctl -u realm -n 100

# Check ports
sudo netstat -tlnp | grep realm
# or
sudo ss -tlnp | grep realm

Performance monitoring

  1. Use top or htop to monitor CPU and memory
  2. Use iftop or nload to monitor network traffic
  3. Check log file size regularly to avoid disk fill
  4. View traffic usage in the WarpTok console

Restart service

# Linux
sudo systemctl restart realm

# Windows (NSSM)
nssm restart Realm

# Manual stop/start
# Find process ID
ps aux | grep realm
# Kill process
kill -9 <PID>
# Restart
realm -c config.toml &

Troubleshooting

Connection failed

  1. Check config file syntax
  2. Verify WarpTok entry IP and port
  3. Use telnet to test connectivity:
  4. telnet 203.0.113.45 1935
  5. Check firewall rules
  6. Review Realm logs for errors

High latency

  1. Switch entry region in WarpTok console
  2. Check local server network quality
  3. Use ping to measure latency to the entry
  4. Consider upgrading server bandwidth

Service exits unexpectedly

  1. Check logs for errors
  2. Ensure sufficient system resources
  3. Verify config file hasn't changed
  4. Use systemd auto-restart

Best practices

Security tips

  1. Do not expose Realm listen ports to the public Internet
  2. If public access is needed, restrict source IPs with a firewall
  3. Update Realm regularly
  4. Use non‑standard ports for added security
  5. Set config file permissions to 600

Performance optimization

  1. Deploy Realm close to your users or servers
  2. Store logs on SSD
  3. Set an appropriate log level to reduce I/O
  4. Clean up old log files regularly
  5. Monitor system resource usage

High availability

  1. Deploy multiple Realm instances for redundancy
  2. Use different WarpTok entry addresses
  3. Configure health checks and failover
  4. Set up monitoring alerts

这篇文章有帮助吗?

如果您还有其他问题,欢迎联系我们的客服团队