WireGuard Dual WAN Failover

Started by UnpeeledTracingMaker, August 07, 2025, 05:43:19 AM

Previous topic - Next topic
Recently switched to OPNsense and I'm trying to run WireGuard with dual WAN failover. However, I'm having some troubles getting it to work. I have the gateways configured to prioritize my primary WAN with the secondary WAN as a lower priority failover. I have a WireGuard instance that connects to a remote cloud VPN that I then policy route my LAN connection to. However, when I test the failover, the WireGuard connection never reconnects.

I tried using the default 1 minute cron job that renews the WireGuard DNS upon a stale connection, but it didn't work, presumably because the connection goes offline and not stale. I also tried using monit to run "/usr/local/sbin/pluginctl -s wireguard restart <my-uuid>" upon not being able to ping the remote, but that also didn't work, even running it manually. The only reliable way I could get the connection working again is to disable then reenable the peer (not the instance) in the web UI. Obviously, I don't want to do that each time and am looking for a command to do this programmatically.

I'd also like to configure WireGuard to switch the connection back to the primary WAN once it's online for say, 1 minute, and not be sticky. Suggestions would be appreciated here.