Skip to main content

Why routing scripts are needed

When you enable a full-tunnel WireGuard VPN (with AllowedIPs = 0.0.0.0/0), all traffic — including packets destined for the TURN server — is sent through the tunnel. This creates a loop: the proxy client tries to reach the TURN server, the OS routes that traffic into the VPN, and the traffic never reaches the TURN server over the real network. The routing scripts solve this by adding a direct host route to the TURN server’s IP via your physical default gateway before you activate the VPN. With that route in place, the OS sends TURN-bound packets directly to the gateway, bypassing the tunnel. The proxy client prints each TURN server IP it resolves to stdout. The scripts read those IPs from stdin and add the corresponding routes.
Routes added by these scripts are not persistent across reboots. If the machine restarts, run the proxy client and routing script again before enabling the VPN.

Scripts

routes.sh — run with sudo or as root.
#!/bin/bash
gateway="$(ip -o -4 route show to default | awk '/via/ {print $3}' | head -1)"
while read -r remote; do
  sudo ip r add $remote via $gateway
done
How it works:
  1. Reads the current IPv4 default gateway using ip route.
  2. Loops over every line from stdin. Each line is expected to be a plain IP address printed by the proxy client.
  3. Adds a host route (ip r add <ip> via <gateway>) for each IP.
Usage:
./client-linux -peer <vps-ip>:56000 -vk-link <vk-link> -listen 127.0.0.1:9000 | sudo routes.sh

Build docs developers (and LLMs) love