AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

i365Finds Editorial is the independent research and editorial organization behind 365 Wiki. We follow changes in tools, products, services, entertainment, and digital life around the world, turning scattered and fast-moving information into clearly sourced, well-structured public content that is easier to understand and compare.
Indexed 90,207 Wiki articles

How Multi-WAN Routers Handle VPN Client Failover Without Dropping Active Sessions

Geraldo Bracamontes Varga · 365Finds Editorial

When a fiber line goes dark during a critical SSH deployment, a VoIP conference, or a database transaction, most multi-WAN setups do something infuriating: they drop every single session. The router proudly switches to cellular backup within three seconds, but by then, your application states are already dead. You find yourself logging back into servers, restarting frozen calls, and cursing marketing claims of "seamless failover."

At 365Finds, we have dissected router failover behaviors across Linux network stacks, BSD firewalls, and enterprise SD-WAN appliances. Achieving genuine session persistence across redundant WAN links is one of the most misunderstood challenges in networking.

A multi-WAN router can maintain active VPN client sessions during a fiber-to-cellular transition, but only if it separates the outer transport path from the inner virtual IP, updates routing metrics without flushing connection tracking tables, and actively manages socket re-binding. Here is how that process actually works under the hood, why naive implementations fail, and what configurations make zero-drop failover possible.


The Core Conflict: Inner Sessions vs. Outer Transports

To understand failover persistence, you have to separate traffic into two distinct layers:

  1. The Inner Payload Layer: The TCP or UDP connection established between a local workstation (192.168.1.50) and a remote server (142.250.190.46). Inside the VPN tunnel, this session is bound to the router's virtual tunnel interface address (e.g., 10.8.0.2).
  2. The Outer Transport Layer: The encrypted UDP or TCP socket established between the router's physical WAN interface and the remote VPN endpoint.
[Local Client: 192.168.1.50]
           │
           ▼ (Inner TCP Stream: 10.8.0.2:54321 ➔ Remote Server)
┌────────────────────────────────────────────────────────┐
│ Multi-WAN Router                                       │
│   Virtual Interface (tun0 / wg0: 10.8.0.2)             │
│   Outer Encapsulated Socket                            │
└────────────┬─────────────────────────────┬─────────────┘
             │ Primary (Metric 10)         │ Backup (Metric 20)
             ▼                             ▼
       [Fiber WAN]                   [Cellular WAN]
       (Public IP A)                 (CGNAT IP B)
             │                             │
             └──────────────┬──────────────┘
                            │
                            ▼
              [Remote VPN Concentrator]
                            │
                            ▼ (Decapsulated Inner Stream)
                  [Target Destination]

When your fiber connection dies, your public IP address changes. If your local applications were communicating directly through the physical WAN, TCP sessions would terminate immediately because the remote destination receives packets from an unfamiliar source IP and responds with a TCP reset (RST).

Inside a VPN tunnel, however, the destination only sees the tunnel IP (10.8.0.2). As long as that inner IP address remains intact and the remote VPN server continues mapping incoming decrypted packets to that same virtual address, the inner TCP stream has no idea that the underlying physical wire changed.

The session drops only when the router tears down the virtual interface, restarts the VPN process, or allows connection tracking tables to freeze.


Why Standard Multi-WAN Failover Kills VPN Sockets

Most dual-WAN consumer routers handle failover with a sledgehammer approach:

  1. A gateway watchdog (dpinger, mwan3track, or an ICMP ping script) detects packet loss on the primary fiber gateway.
  2. The router updates its routing table, raising the fiber route metric and making the cellular interface the default gateway.
  3. The firewall daemon triggers an interface reset, tearing down existing socket bindings and flushing the kernel connection tracking table (conntrack on Linux or pf states on BSD).
  4. The VPN client daemon (often OpenVPN or standard IPsec) detects interface failure, terminates its socket, and attempts a full re-authentication over the cellular connection.

The moment the VPN interface (tun0) disappears, the kernel invalidates the routing prefix. Inner TCP connections instantly break. Even if the cellular connection comes up within two seconds, the TLS handshake and key renegotiation wipe out state continuity.

To avoid dropping active sessions, the router must execute failover without tearing down the virtual tunnel interface or resetting the inner state table.


Architectural Mechanism 1: WireGuard Cryptographic Roaming

WireGuard handles dynamic IP changes more elegantly than legacy VPN protocols because it is inherently stateless. It has no continuous tunnel negotiation daemon; it relies entirely on Cryptokey Routing.

How It Works

A WireGuard interface binds to a UDP port on 0.0.0.0 rather than a single physical interface IP. When the router switches its active default route from fiber to cellular:

  1. The next outbound WireGuard packet leaves via the cellular WAN interface, taking on the cellular connection's public (or CGNAT) source IP.
  2. The packet reaches the remote WireGuard server with valid cryptographic authentication.
  3. The remote server immediately updates the peer's endpoint IP and port in its internal routing table to match the new cellular address.
  4. Return packets are routed directly back to the cellular interface.

The inner tunnel interface (wg0) never cycles down. Its IP address (10.x.x.x) remains unchanged, and internal TCP sockets continue transmitting packets.

Failover Event:
1. Fiber Link Fails ──> Gateway Monitor detects packet loss (1.5s)
2. Metric Shift      ──> Outbound default route switches to Cellular
3. WireGuard Packet  ──> Sent via Cellular with existing cryptographic keys
4. Server Endpoint   ──> Server updates peer endpoint to new Cellular IP
5. Inner Sessions    ──> Zero teardown; TCP sequences resume

The Netfilter Conntrack Trap

While WireGuard theoretically supports instantaneous roaming, real-world Linux router implementations (like OpenWrt with mwan3) frequently hang during failover.

This happens because the Netfilter connection tracking table (conntrack) holds an established UDP translation mapping between the router and the WireGuard server's public endpoint, pegged to the dead fiber gateway. Packets sent by WireGuard remain stuck in that stale state rather than routing over the cellular path.

If the router executes a global conntrack flush (conntrack -F), it fixes the WireGuard socket but terminates all local client TCP connections running through the router.

The correct implementation requires a targeted script hook in the multi-WAN daemon:

# /etc/mwan3.user or post-routing failover trigger
# Clear ONLY the outer WireGuard server socket from conntrack
VPN_SERVER_IP="198.51.100.5"

if [ "$ACTION" = "disconnected" ] && [ "$INTERFACE" = "wan1_fiber" ]; then
    conntrack -D -d "$VPN_SERVER_IP" -p udp
fi

By clearing only the outer UDP endpoint state, the router forces the kernel to establish a fresh connection tracking entry over the cellular interface while leaving every inner LAN-to-VPN TCP stream untouched. Setting PersistentKeepalive = 2 ensures that a handshake packet traverses the backup link within two seconds of the switch.


Architectural Mechanism 2: IKEv2 with MOBIKE (RFC 4555)

For enterprise environments running IPsec, the standard solution for session survival across multi-WAN links is MOBIKE (IKEv2 Mobility and Multihoming Protocol, defined in RFC 4555).

Traditional IPsec binds Security Associations (SAs) strictly to a pair of static IP addresses. If the fiber link drops and traffic routes through cellular, the remote gateway rejects incoming IPsec packets because they originate from an unauthorized IP.

Client (Multi-WAN)                                  Remote Gateway
──────────────────                                  ──────────────
[Fiber Down!]
Switch to Cellular
Send INFORMATIONAL ── UPDATE_SA_ADDRESS ───────────>
                    <── Path Probe (Cookie) ─────────
Path Verified ──────> [Update SA to Cellular IP]
Existing SA Continues (Inner TCP Sessions Preserved)

The MOBIKE Handshake Process

  1. Interface Monitoring: The router's IPsec daemon (such as strongSwan) monitors local routing metrics and interface states.
  2. Dynamic Update Notification: When the fiber gateway becomes unreachable, the client initiates an INFORMATIONAL exchange over the cellular interface containing the UPDATE_SA_ADDRESS notification.
  3. Return Routability Verification: To protect against spoofing and traffic amplification attacks, the remote gateway sends a path probe with a cryptographic cookie to the client’s new cellular IP.
  4. SA Migration: Once verified, the gateway updates its Security Association database to the new cellular IP without renegotiating encryption keys or dropping Child SAs.

The entire exchange occurs on UDP port 4500 (NAT-T), allowing MOBIKE to operate seamlessly through carrier-grade cellular NAT. Inner sessions experience only a momentary latency spike.


Architectural Mechanism 3: Dual Active Tunnels with BGP/BFD

In mission-critical branch-to-datacenter architectures, we rarely rely on a single tunnel renegotiating or roaming over a new WAN. Instead, the router maintains two independent, concurrent VPN tunnels at all times:

Both tunnels terminate at the same centralized VPN concentrator.

[Local LAN] ──> [Router Virtual Routing Engine]
                     │
         ┌───────────┴───────────┐
         ▼                       ▼
  [Tunnel 1: Fiber]       [Tunnel 2: Cellular]
  (Active: Metric 10)     (Standby: Metric 20)
  (BFD Echo: 100ms)       (BFD Echo: 100ms)
         │                       │
         └───────────┬───────────┘
                     ▼
          [Data Center Concentrator]

To provide sub-second failover without session loss:

  1. Dynamic Routing: BGP or OSPF runs inside the encrypted tunnels across both links simultaneously.
  2. BFD (Bidirectional Forwarding Detection): BFD sends microscopic keepalive packets across Tunnel 1 every 100 milliseconds.
  3. Instant Convergence: When the fiber physical plant drops, BFD detects three consecutive missed hellos within 300 milliseconds. It immediately flags Tunnel 1 as dead.
  4. Metric Update: The routing engine repoints the internal subnet's next-hop to Tunnel 2.

Because Tunnel 2 is already fully authenticated, active, and holding its own cryptographic state, traffic transitions within 300 milliseconds. The remote concentrator simply routes returning packets through Tunnel 2. No TCP streams reset, and VoIP calls don't even stutter.


Failover Comparison Across Technologies

Failover MechanismProtocol / EngineFailover TimeSession Survival RateCellular Data OverheadConfiguration Complexity
Surgical Conntrack RoamingWireGuard1.0 – 2.5 secondsHigh (if conntrack handled)Very Low (idle keepalives)Moderate
MOBIKE (RFC 4555)IKEv2 / IPsec1.5 – 3.0 secondsHighLowHigh
Dual Tunnel BFDIPsec / WireGuard + BGP200 – 400 msNear 100%Low to ModerateVery High
Packet-Level BondingPeplink SpeedFusion / SD-WANSub-millisecond100%High (with WAN smoothing)Proprietary / Cloud
Naive Default WAN SwitchStandard OpenVPN / IPsec10 – 30 seconds0% (Total Drop)ZeroLow

The Harsh Realities of Failing Over to Cellular

Keeping socket states alive across routing metrics is only half the battle. Cellular connections have physical and carrier-level characteristics that frequently destroy surviving sessions if not properly planned:

1. Carrier-Grade NAT (CGNAT) and Asymmetric Routing

Almost all cellular modems receive a private RFC 6598 IP (100.64.0.0/10) or standard RFC 1918 address from mobile carriers. Inbound connections to the router over cellular are impossible.

This means the router must be the initiator of all tunnel updates. If a router attempts to maintain a peer-to-peer tunnel where the remote side initiates traffic, failover to cellular will fail completely unless the router proactively sends an outbound handshake packet.

2. MTU and MSS Clamping Disasters

Fiber links routinely support a 1500-byte MTU, leaving plenty of room for VPN encapsulation. Cellular networks (LTE and 5G) frequently enforce native MTUs of 1420, 1380, or even 1280 bytes due to carrier tunneling protocols (GTP-U).

When an active 1400-byte TCP packet suddenly routes through the cellular VPN tunnel, the packet exceeds the carrier's MTU. If the "Don't Fragment" (DF) bit is set and Path MTU Discovery (PMTUD) fails, the connection stalls completely. The session remains open in the routing table, but data stops moving.

To fix this, the router must enforce dynamic TCP Maximum Segment Size (MSS) clamping on all tunnel interfaces:

# Clamp MSS to Path MTU on packet forwarding
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
# Or explicitly cap inner MSS to 1280
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1280

3. Latency Spikes and TCP Window Shrinkage

Fiber connections typically offer 5 to 15 ms of latency with minimal jitter. Cellular connections fluctuate between 40 and 150 ms, often suffering from bufferbloat during sudden traffic bursts.

When failover occurs, the sudden jump in Round-Trip Time (RTT) can trigger TCP retransmission timeouts (RTO) on overly sensitive enterprise applications. Setting queue management algorithms like CAKE or FQ-CoDel on the cellular interface is essential to keep packet queues from inducing artificial drops during the failover surge.


Practical Deployment Guidelines

If you are designing a multi-WAN router setup to preserve VPN sessions during fiber drops, we at 365Finds recommend these engineering priorities:

  1. Avoid standard OpenVPN client tunnels for multi-WAN failover. OpenVPN's reliance on explicit virtual adapters and TLS renegotiation makes zero-drop failover nearly impossible without complex multi-path overlays.
  2. If using WireGuard on OpenWrt or pfSense: Do not rely on default failover rules. Implement an event script to prune the outer VPN endpoint socket from conntrack upon interface degradation, and lock PersistentKeepalive to 2 seconds.
  3. If using IPsec: Ensure MOBIKE is explicitly enabled on both the client router and the remote gateway (mobike=yes in strongSwan), and verify that UDP port 4500 is unobstructed by carrier firewalls.
  4. Tune Gateway Probes Realistically: Setting gateway watchdog timeouts too aggressively causes flapping (route oscillation) during momentary fiber micro-bursts. A 1.5-second failure threshold with 3 consecutive dropped probes is the operational sweet spot to prevent premature failover while beating standard TCP session drop timers.

A surviving TCP session is fundamentally a race against time: your router's watchdog detection and socket re-binding must complete before the application's TCP retransmission timeout expires. With proper metric isolation and state preservation, that transition happens cleanly within two seconds, keeping your active connections completely alive.


References