OPNsense plugin · os-wan-failover 1.4

WAN Failover

Decides when an IPv4 WAN leaves service and when it comes back, moves connections to the right WAN in both directions, and restarts Tailscale only when the default route really changed.

Why this plugin

Core's gateway monitor marks a WAN down when its loss crosses the gateway's threshold, and up again as soon as its reading drops back under it. On a link that drops packets in bursts, that flaps: the WAN leaves, returns while still lossy, and leaves again, and every change re-elects the default route. Connections opened during an outage stay on the other WAN after the preferred one recovers, because pf keeps a state on the path it was created on. Connections pinned to the failed WAN stay pinned to it. Tailscale, which picks its path once, keeps the old one.

The plugin turns that into one decision with hysteresis: a WAN goes out on loss and comes back only once it is clean.

How it decides

It evaluates every minute, on every gateway monitor alarm and after a configuration change.

Moving connections

On a hold, the states routed via that WAN's gateway and interface are killed, so its connections reconnect over the other WAN at once instead of timing out.

On recovery, the connections that prefer the recovered WAN, by their rule's gateway or gateway-group tier or otherwise by the default route, are ended once the firewall already routes them there, so they reconnect through it. The failback delay (10 minutes by default) makes that wait until the WAN has read clean for that long; any loss restarts the wait, and a WAN held again never gets them back. Fail back now on the page ends the wait.

Tailscale is restarted when the IPv4 default route moves to another gateway and stays there, so it reconnects on the new path, and only then.

Settings

On System > Gateways > WAN Failover, with its log under WAN Failover Log.

SettingWhat it doesNormally
EnableHold, release, move connections and restart Tailscale as above. Off releases every hold at once.On
Dry runDecide and log only: nothing is held, killed or restarted. Watch what it would do before letting it act.On by default; off once you trust it
WAN gatewaysThe IPv4 gateways to manage, normally the two WANs. Only saved gateways are listed: save an automatic gateway once on System > Gateways > Configuration to select it.Both WANs
Move connections backEnd the connections that prefer a recovered WAN so they reconnect through it.On
Failback delay (minutes)How long a recovered WAN must read clean before connections move back. 0 moves them as soon as the WAN is released.10
Restart TailscaleRestart tailscaled on a real IPv4 default-route change.On with Tailscale

Command line

configctl wanfailover holds          # JSON: each WAN's reading and judgement, whether it is held, any failback wait
configctl wanfailover status         # whether the plugin's minute job is installed
configctl wanfailover failback_now   # end the failback delay
configctl wanfailover release        # release every hold now

Limits

Source and install

Install it from the LegoTypes repository: see Install. Source: LegoTypes/plugins, net/wan-failover.