OpenWrt WireGuard Auto-Reconnect Workaround
When using WireGuard on OpenWrt with dynamic DNS, a peer IP change may leave the tunnel stale after many hours. In some environments it does not recover automatically and requires manual restart.
Method 1: Custom script
|
|
Method 2: Built-in OpenWrt watchdog script
OpenWrt includes /usr/bin/wireguard_watchdog (content omitted here for brevity). It checks peer handshake activity and can re-resolve endpoint hostnames when a peer is idle too long.
Run by cron
Use cron to execute the watchdog periodically.
Via Web UI
- Open
System -> Scheduled Tasks. - Add:
|
|
Via SSH
- SSH into OpenWrt.
- Run
crontab -e. - Add:
|
|
- Save and restart cron if needed.