Running as a Service
Set up rVPN server to start automatically on boot and restart on failure.
systemd (Linux)
Section titled “systemd (Linux)”Create the service file:
sudo nano /etc/systemd/system/rvpn-server.service[Unit]Description=rVPN ServerAfter=network-online.targetWants=network-online.target
[Service]Type=simpleUser=rootExecStart=/usr/local/bin/rvpn-server -c /etc/rvpn/server.tomlRestart=on-failureRestartSec=5LimitNOFILE=65536
# Redirect logs to journalStandardOutput=journalStandardError=journalSyslogIdentifier=rvpn-server
[Install]WantedBy=multi-user.targetEnable and start:
sudo systemctl daemon-reloadsudo systemctl enable rvpn-serversudo systemctl start rvpn-serverCheck status:
sudo systemctl status rvpn-serverView logs:
sudo journalctl -u rvpn-server -fManaging the Service
Section titled “Managing the Service”| Action | Command |
|---|---|
| Start | sudo systemctl start rvpn-server |
| Stop | sudo systemctl stop rvpn-server |
| Restart | sudo systemctl restart rvpn-server |
| View logs | sudo journalctl -u rvpn-server -f |
| Disable autostart | sudo systemctl disable rvpn-server |
The server does not support systemctl reload — the process has to restart to pick up config or certificate changes. Use restart where you might reach for reload elsewhere.
TLS Certificate Auto-Renewal
Section titled “TLS Certificate Auto-Renewal”If you’re using the built-in [server.acme] block (Server Quick Start step 3), there is nothing to configure here — renewal is driven by a background task inside rvpn-server, uses the same :443 listener for the challenge, and hot-swaps the fresh cert into the in-memory resolver without dropping connections. Skip this section.
If instead you’re pointing tls_cert_file / tls_key_file at a certbot-issued cert (BYO cert mode), add a deploy hook to restart rVPN when the certificate renews — the server can’t reload a new cert without restarting:
sudo nano /etc/letsencrypt/renewal-hooks/deploy/rvpn-reload.sh#!/bin/bashsystemctl restart rvpn-serversudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/rvpn-reload.shTest the renewal process:
sudo certbot renew --dry-runFreeBSD rc(8)
Section titled “FreeBSD rc(8)”Create /usr/local/etc/rc.d/rvpn_server:
#!/bin/sh# PROVIDE: rvpn_server# REQUIRE: NETWORKING# KEYWORD: shutdown
. /etc/rc.subr
name="rvpn_server"rcvar="rvpn_server_enable"command="/usr/local/bin/rvpn-server"command_args="-c /usr/local/etc/rvpn/server.toml"pidfile="/var/run/rvpn-server.pid"
load_rc_config $namerun_rc_command "$1"chmod +x /usr/local/etc/rc.d/rvpn_serverecho 'rvpn_server_enable="YES"' >> /etc/rc.confservice rvpn_server startEgress Prerequisites for TUN Mode
Section titled “Egress Prerequisites for TUN Mode”The server installs its containment and optional NAT when the service starts; failure is fatal before clients are accepted. Firewall state is reconciled on every restart, so no separate iptables-persistent or netfilter-persistent rules are needed for rVPN.
Enable net.ipv4.ip_forward=1 permanently and install iptables plus ip6tables. The service needs permission to create the TUN device and manage netfilter. rVPN changes only its RVPN_* chains and TUN-specific jumps; existing global rules and policies are not flushed. nat_enabled = false disables only NAT.
FreeBSD
Section titled “FreeBSD”Run the service as root, enable forwarding and PF, and pre-provision both entries in the active main ruleset before broad pass quick rules:
nat-anchor "rvpn"anchor "rvpn"The server never edits or reloads main PF rules, flushes state, or uses ipfw/natd. It validates and loads only the rvpn anchor. Missing prerequisites stop TUN startup; see TUN Mode for the scoped commands and anchor path.
macOS does not support server-side TUN NAT. Use SOCKS5 mode or a Linux VM for TUN mode servers.
TUN Mode vs SOCKS5 Mode
Section titled “TUN Mode vs SOCKS5 Mode”| Aspect | TUN Mode | SOCKS5 Mode |
|---|---|---|
| NAT required | Yes (server-side) | No (client-side relay) |
| Traffic routing | All apps, full tunnel | Per-application |
| Server setup | IP forwarding + NAT rules | Standard VPN server |
See TUN Mode for complete TUN mode setup documentation.