Hello everyone,
I’m running OpenWrt on a GL-AXT1800 router with a single WireGuard tunnel (wg0
) pointed at one of four VPN servers in different countries:
- France
- Mexico
- USA
- Canada
I’d like to automatically switch the tunnel’s Endpoint
to the next country’s server every 15 minutes. So far I’ve tried:
- Cron job invoking a shell script locally
- Background loop script via SSH
Neither solution has worked reliably—cron runs the script but the endpoint never changes, and the SSH‐loop often freezes the router requiring a reboot.
What I’m Looking For
- A lightweight, stable method (ideally without heavy extra packages)
- Rotation of the WireGuard
Endpoint
every 15 minutes - Minimal impact on router stability and performance
What I’ve Tried
*/15 * * * * /root/rotate_vpn.sh
Excerpt from rotate_vpn.sh
!/bin/sh
endpoints=(
France
Mexico
USA
Canada
)
pub="<SERVER_PUBLIC_KEY>"
idx=$(cat /root/vpn_index 2>/dev/null || echo 0)
next=$(( (idx + 1) % 4 ))
endpoint=${endpoints[$next]}
wg set wg0 peer "$pub" allowed-ips 0.0.0.0/0 endpoint "$endpoint" || echo "Failed to set endpoint"
echo "$next" > /root/vpn_index
**
After the job runs, wg show wg0
still shows the previous endpoint, and sometimes the router becomes unresponsive.
Has anyone successfully implemented endpoint rotation on OpenWrt / GL-AXT1800?**
Any pointers, whether using UCI, a minimal cron alternative, a firmware tweak, or a simple shell trick, would be greatly appreciated.
Version
4.8.0
Firmware Type
beta5
OpenWrt Version
OpenWrt 23.05-SNAPSHOT r23485+125-e92cf0c46f
Kernel Version
5.4.164
Thanks in advance!