[Guide] ProtonVPN WireGuard Failover with Gateway Groups

Started by mlenje, Today at 07:14:48 AM

Previous topic - Next topic
    ProtonVPN WireGuard Failover with Gateway Groups - plus a shared-address NAT gotcha that will silently break your second tunnel

    TL;DR
    • Building automatic failover between two simultaneous ProtonVPN WireGuard tunnels on OPNsense using Gateway Groups.
    • Every ProtonVPN WireGuard config shares the identical internal address 10.2.0.2, by design, account-wide. Editing the local [Interface] Address on a second tunnel is necessary but not sufficient - ProtonVPN's server keeps replying to 10.2.0.2 regardless, which silently breaks dpinger monitoring on the second tunnel (route looks fine, manual ping/tcpdump looks fine, but gateway status sits at 100% loss forever).
    • The fix is NAT on both directions (1:1 BINAT inbound + Outbound NAT translating to the literal shared address), not a routing/firewall-rule change.
    • Full walkthrough below, plus the failover Gateway Group setup and a real-world tested failover/failback procedure.

    Credit where due: the core of the NAT fix is adapted from this pfSense/ProtonVPN writeup by u/FarsightMeercat, which documents the identical problem independently, just for pfSense rather than OPNsense. I only found it after burning a fair amount of time chasing this myself - hoping this post saves the next OPNsense person that search.



    Background / prerequisite

    This assumes you already have one working ProtonVPN WireGuard tunnel on OPNsense with accurate gateway monitoring (dpinger genuinely reflecting up/down, not silently stuck on a fake-healthy state). If your single-tunnel monitoring isn't already solid, get that right first - a broken foundation makes failover testing impossible to interpret.

    The most common way single-tunnel monitoring silently breaks: the WireGuard instance's own Gateway field (VPN > WireGuard > Instances > edit) must exactly match the System Gateway's IP Address field (System > Gateways > Configuration). A mismatch causes OPNsense to find an unrelated pre-existing host route and skip building the real one - no error in the general log, dpinger just reports a fake-healthy "none" status forever. Worth double-checking this even on an existing single-tunnel setup.



    Part 1: Create the second WireGuard instance

    Generate a second ProtonVPN WireGuard config (different server than your primary tunnel, ideally different physical facility for real redundancy).

    Before importing it into OPNsense, edit its [Interface] Address line. Every ProtonVPN config download shows the identical 10.2.0.2/32, regardless of server - confirmed directly with ProtonVPN support: this is intentional, "to avoid static, identifiable patterns," not a per-device assignment. Their own guidance for running multiple tunnels: manually edit each additional config's Address to something unique.

    Example addressing scheme:
    Primary (existing) ......... 10.2.0.2/32
    Second tunnel (new) ........ 10.4.0.2/32

    VPN > WireGuard > Instances > Add:
    Public/Private Key .... from the new config
    Listen Port ............ any unused port
    Addresses ............... 10.4.0.2/32 (edited, NOT the file's original 10.2.0.2/32)
    MTU ..................... match your primary (commonly 1420)
    DNS Server .............. file also shows a shared 10.2.0.1 - edit this too,
     following the same pattern (10.4.0.1). Note: ProtonVPN
     only confirmed the Address field is shared-by-design;
     I haven't gotten separate confirmation the DNS Server
     field behaves the same way. If DNS fails over the new
     tunnel, fall back to testing the original literal value.
    Disable Routes .......... checked - leave routing entirely to the System
     Gateway object, don't let the WireGuard instance
     push its own routes
    Gateway ................. LEAVE BLANK FOR NOW

    Attach the peer, enable, apply.



    Part 2: Set the instance's Gateway field correctly the first time

    • With the instance up, confirm a real handshake: wg show <device>
    • Set the instance's Gateway field. In my case, the working pattern was "one address up from the tunnel address" (10.2.0.2 â†' gateway 10.2.0.3), so I tried the same for the second tunnel: Address 10.4.0.2 â†' Gateway 10.4.0.3. Worked first try.
    • Save, apply.

    Don't invent an arbitrary placeholder IP here. This exact mistake is what breaks single-tunnel monitoring in the first place (see Background above) - same failure mode applies to a second tunnel.



    Part 3: Assign the WireGuard device as an interface

    Easy to forget if your primary tunnel already went through this step long ago and you don't remember doing it. A WireGuard instance existing isn't enough on its own - it won't show up in Gateway/NAT/Firewall dropdowns until explicitly assigned.

    Interfaces > Assignments: select the new device, add it, enable, set a clear Description (I used VPNClient_Wireguard_Rollover), leave IPv4 Configuration Type as none.

    Naming note: the WireGuard instance's own Name field and the assigned interface's Description field are two separate labels for the same tunnel, shown on different screens - Name shows under VPN > WireGuard, Description shows in Gateways/NAT/Firewall dropdowns. Easy to assume they're the same field; they're not.



    Part 4: Create the System Gateway object

    System > Gateways > Configuration > Add:
    Interface ........... the interface assigned in Part 3
    IP Address ........... EXACTLY the Gateway field value from Part 2
    Far Gateway ........... checked
    Monitor IP ............ anything distinct from your primary tunnel's
     monitor IP, for easy at-a-glance distinction
    Disable Host Route .... unchecked

    Save, apply.



    Part 5: Verify routing - and expect the next failure

    route get <monitor IP>Should resolve via the new tunnel interface.

    tcpdump -ni <new interface> icmpConfirm real ICMP traffic while pinging the monitor IP from the firewall.

    At this point, dpinger_status() will likely still show the new gateway as status => down, 100% loss, 0.0ms delay/stddev - even though the route and manual ping both look completely healthy. This tripped me up for a while because it looks like the exact same bug from the Background section, but it isn't - recheck nothing, go straight to Part 6.



    Part 6: The actual fix - ProtonVPN's shared address requires NAT, not routing changes

    Here's what a tcpdump -ni <new interface> capture during this "down" state actually showed:
    <new tunnel's real address> > <monitor IP>: ICMP echo request
    <monitor IP> > 10.2.0.2: ICMP echo reply

    The request leaves correctly from the tunnel's real edited address. The reply comes back addressed to 10.2.0.2 - the original shared ProtonVPN address, not the edited local one. ProtonVPN's server-side infrastructure still associates your registered device/key with 10.2.0.2 internally, regardless of what you configure locally. Since nothing on the box (that dpinger's probe socket is bound to, anyway) owns that address anymore, the reply never reaches the monitor - even though the tunnel itself is completely healthy and passing traffic.

    This is a documented ProtonVPN limitation for anyone running 2+ simultaneous WireGuard tunnels from one account, not something fixable via local routing/firewall-rule tweaks, and not fixable by regenerating the peer (ProtonVPN's Peer Generator doesn't let you choose this address).

    The fix, adapted from the pfSense writeup linked above - NAT on both directions:

    1. Inbound: NAT 1:1 (BINAT), scoped to the new tunnel's interface only

    Firewall > NAT > 1:1 > Add:
    Interface ........ your new tunnel's interface - CRITICAL: must not be
     your primary tunnel's interface
    Type .............. BINAT
    External network .. 10.2.0.2/32
    Source ............ Single host or Network â†' your tunnel's real edited
     address (e.g. 10.4.0.2/32)
    Destination ....... any

    2. Outbound: Source NAT, translating LAN traffic to the address ProtonVPN actually recognizes

    Firewall > NAT > Outbound (Source NAT) > Add:
    Interface ............. your new tunnel's interface
    Source ................ LAN network
    Destination ........... any
    Translate Source IP ... Single host or Network â†' 10.2.0.2 (literal) - 
     do NOT use "Interface address", which would
     translate to your synthetic edited address,
     which ProtonVPN doesn't recognize as a
     registered device; traffic would go out and
     get silently dropped

    Save and apply both. Rule order relative to other outbound rules doesn't matter - pf matches outbound NAT by scoped interface, so a packet leaving via your new tunnel can only match a rule scoped to that same interface.

    Restart dpinger and re-check:
    pluginctl -s dpinger restartThe new gateway should now show status => none with real non-zero delay/stddev and 0.0% loss.



    Part 7 (optional but recommended): Floating rule for self-originated traffic

    Not the fix for Part 6's issue, but worth having for consistency if your primary tunnel already has one. This affects routing for traffic the firewall generates itself (dpinger's own probes, manual curl/ping from the firewall shell) - separate from Part 6's address translation fix.

    Firewall > Rules > Floating > Add:
    Interface ................. any
    Direction .................. In
    Action ...................... Pass
    Source ....................... new tunnel's interface address alias
    Destination ................... new tunnel's interface network alias
    Gateway (Source Routing) ...... your new System Gateway



    Part 8: Monit alerting + watchdog

    Same pattern as any dpinger-based gateway monitoring. A couple of gotchas worth flagging if you haven't already run into them on your primary tunnel:

    • Cron's "Minutes" field: "2" means "once per hour at :02," not "every 2 minutes." Use */2.
    • Cron only runs predefined configd actions - you need a .conf file under /usr/local/opnsense/service/conf/actions.d/ plus a configd restart before the action appears in the Cron job dropdown. Use "service configd restart" - "configctl configd restart" will error with "Action not allowed or missing," since configd can't restart itself through its own action-dispatch mechanism.
    • Don't trust crontab -l or /etc/crontab to confirm a GUI-managed cron job is actually scheduled - both came back empty for a legitimately-configured, working job in my case. System > Settings > Cron in the GUI is the reliable source of truth. If you want airtight proof of execution (not just that it's configured), temporarily add an unconditional trace line to the top of the script, wait a few cron cycles, and check for timestamped entries.
    • dpinger doesn't reliably self-clear a stuck "down" state after a real outage resolves - a small watchdog script comparing WireGuard's own handshake freshness against dpinger's reported status, restarting dpinger only when they disagree, fixes this. "pluginctl -s dpinger restart" restarts all dpinger instances on the box (global side effect, not a bug) - worth folding multiple tunnels' checks into one combined watchdog rather than running several independent ones that'll all trigger the same restart anyway.


    Part 9: Create the Gateway Group

    System > Gateways > Group > Add:
    Gateway Priority ... primary â†' Tier 1, new tunnel â†' Tier 2
    Trigger Level ....... Member Down to start (tighten to packet-loss/
     latency thresholds later once you trust it)



    Part 10: Point LAN policy routing at the Gateway Group

    Firewall > Rules > LAN - find the rule enforcing your VPN gateway for LAN egress (source LAN network, destination !RFC1918_Networks). Change its Gateway field from the single primary gateway to the new Gateway Group. Leave other LAN rules untouched.



    Part 11: Test failover and failback properly

    • Confirm baseline: both gateways healthy, traffic only on the primary tunnel.
    • Disable the primary WireGuard instance (cleaner than physically blocking - exercises the real failure mode dpinger detects).
    • Confirm dpinger flips the primary to "down," confirm any Monit alert fires.
    • Test from an actual LAN client, not the firewall's own SSH shell. Self-originated firewall traffic follows different routing than forwarded LAN traffic (same category of gotcha as dpinger's own probes needing the Part 7 floating rule) - a curl ifconfig.me run directly on the firewall can silently fall through to raw WAN and give you a false negative. From a real device on your LAN: curl ifconfig.me should show the second tunnel's exit IP.
    • Re-enable the primary, confirm recovery, re-run the LAN-client test to confirm traffic shifted back.

    In my case, this all worked cleanly end to end - failover and failback both confirmed with real client traffic, not just internal monitoring state.



    Summary of gotchas that cost the most time

    • WireGuard instance Gateway field and System Gateway IP Address field must match exactly, for every tunnel - no placeholders.
    • ProtonVPN WireGuard configs all share the same internal address (10.2.0.2) by design, account-wide. A local Address edit alone is not sufficient for a second simultaneous tunnel - you need NAT 1:1 (inbound) + Outbound NAT translating to the literal 10.2.0.2 on the new tunnel's interface.
    • Self-originated firewall traffic (dpinger probes, a manual curl/ping from the SSH shell) follows different routing than real LAN client traffic - always validate failover from an actual LAN device.
    • A WireGuard instance's Name field and its assigned interface's Description field are two different labels for the same tunnel on different screens.
    • pluginctl -s dpinger restart is global, not per-gateway.

    Happy to answer questions if anyone's attempting the same setup - and if anyone's got independent confirmation on the DNS Server field's shared-by-design behavior (see Part 1), I'd love to know either way.