Local Subnet: Isolated locker VLAN (vlan60-lockers, 10.60.0.0/24)
We deploy branch banks for an on-prem smart locker system inside remote lobbies where the local locker controller connects back to our central server over a WireGuard tunnel (wg-hq) and maintains a persistent MQTT TLS session (8883/tcp) for compartment unlock commands and audit logs.
Symptom When ether1 drops, recursive routing fails over to lte1 within ~10 seconds—however, the WireGuard tunnel and MQTT socket stay dead until manually reset because old UDP/TCP srcnat entries bound to the downed ether1 public IP remain stuck in /ip/firewall/connection.
Verified wg-hqpersistent-keepalive=25s, which keeps trying to send packets out using the stale srcnat reply-dst-address from ether1.
Manually running /ip/firewall/connection/remove [find where dst-address~"<hq-ip>"] immediately restores both WireGuard and MQTT over lte1.
Is the cleanest RouterOS v7 fix to trigger a /tool/netwatch down-script to flush those specific srcnat connection-tracking entries on failover, or switch from masquerade to src-nat / separate routing tables so WireGuard rebinds cleanly?
The cleanest solution I've found thus far is periodically running a script that checks the last-handshake value for the wireguard peer (let's say once a minute), and if it'l nil or bigger than 180s, it changes the listen port for the wg interface. My way is to cycle through a range of ports, let's say from 15000-15099.
This has the effect of creating a new srcnat entry and letting the old one time out, plus it clears up some other potential problems as well (which may not impact you at the moment.)
I think it doesn't help in OP's case, because WG is not running on the router but on a separate device. The conntrack entry is of the forwarded UDP "connection".
If I remember correctly masqueraded conntrack entries should be removed automatically when ether1 is really down (unplugged or disabled). Also, if OP upgrade RouterOS to something >= 7.21 (instead of 7.16.2) then the masqueraded conntrack entries will also be removed by RouterOS when the IP addresses on ether1 changes.
However, currently nothing is done if the WAN via ether1 fails without the state of ether1 changing (for example when ISP ONT loses the optical connection). So Netwatch is probably the best solution.