← Back to Create

After tunnel setup

Create builds a tunnel and keeps it correct, but it does not decide which traffic uses it: that stays on core's pages, each linked from the Tunnel references table. A few reminders, not a rehash of the OPNsense documentation.

Gateway groups

Put the tunnels' gateways in a group, tiered by preference. With two WANs, the tunnels bound to your preferred WAN take the top tiers and the other WAN's tunnels the tiers below them; a second, mirrored group prefers the other WAN. A rule then chooses its preferred WAN by choosing the group. Because the plugin forces a tunnel down with its WAN, a WAN outage moves that group's traffic to the other WAN's tunnels. With one WAN, one group tiered by tunnel is enough. IPv4 and IPv6 gateways need separate groups.

GroupTier 1Tier 2Tier 3Tier 4
vpn_via_primaryvpn-primary-1vpn-primary-2vpn-secondary-1vpn-secondary-2
vpn_via_secondaryvpn-secondary-1vpn-secondary-2vpn-primary-1vpn-primary-2

Illustrative names. The IPv6 groups mirror these with each tunnel's IPv6 gateway. The names say which WAN a tunnel rides and its position, and which WAN a group prefers, never which server is behind a tunnel. A server swap then changes no gateway, group or rule (see Name it for its use on your firewall, not its endpoint).

Policy rules

On each interface whose traffic should use a tunnel, a pass rule with the group as its gateway and a destination that excludes local networks: an inverted alias of your private ranges (including the tailnet and ULA ranges, if you use them) never catches local traffic, whatever the rule order. Write one rule per IP version, each naming the group of its own family; core silently disables a rule whose IP version differs from its gateway's. The rule's source must also be one of the tunnel's NAT sources (Edit), or the plugin's guard drops the untranslated traffic.

Failing closed

A policy rule normally fails closed. When every member of its group is down, core keeps the rule routed into tier 1, and a rule that names one tunnel gateway keeps that gateway while it is down, so the traffic dies in a dead tunnel instead of leaving by a WAN. There are two gaps, both from a disabled gateway:

Skip rules when gateway is down (Firewall: Settings: Advanced) disables a rule whose gateway or group resolves to nothing, so it covers both gaps. But it is global, applying to every rule that names a gateway, and it blocks nothing: with the rule skipped, a later rule can still pass the same traffic out of a WAN. A tag covers both gaps, blocks the traffic, and touches nothing else.

A VPN-only tag

Every policy rule that sends traffic into a tunnel group marks it with a local tag, and one rule drops anything carrying that tag at the WANs. The tunnels themselves are unaffected: WireGuard drops the tag when it wraps a packet, so a tunnel's own encrypted traffic leaves its WAN as before. Replies to tagged traffic leave by the client's own interface, which is why only the WANs need the block. While every group resolves, the block matches nothing.

The plugin does not write this for you. The tag has to be set by your own policy rules, and a plugin that edited your rules, or tried to work out which traffic they send into a tunnel, would be the riskiest kind of firewall plugin. It takes two steps on Firewall: Rules:

  1. Tag each policy rule. In every pass rule whose gateway is a tunnel group or a tunnel gateway, set Set local tag (an advanced field) to VPN_ONLY. Do it for the IPv4 and the IPv6 rule alike, and for every new policy rule you add later. A rule that already sets another tag cannot carry this one too: give it its own block rule, or use one tag for both purposes.
  2. Block the tag at the WANs, once. A rule with Action Block, Quick, Interface every WAN (for two WANs, select both), Direction out, Version any, Protocol any, Source and Destination any, Match local tag (an advanced field) VPN_ONLY, Log on. A rule on several interfaces is listed under core's Floating rules: place it first there, above anything that could pass the same traffic out of a WAN. With one WAN it is an ordinary rule on that WAN, evaluated after every Floating and interface-group rule, so check that none of those passes the same traffic out first.

Illustrative tag name; any name works if both steps use it. To check it on the console: pfctl -sr | grep ' tag VPN_ONLY' | grep -vc route-to prints 0 while every group resolves (every tagged rule still carries its gateway), and pfctl -vsr shows the tagged VPN_ONLY block at 0 packets. A count that grows on the block means a policy rule lost its gateway and the block caught what would have leaked.

Kill states

Turn on Failover States (core's option for killing a gateway's states) for the tunnel gateways. Failover by itself moves only new connections; existing ones stay pinned to the dead tunnel until they time out. That matters most when a WAN outage moves a group to the other WAN's tunnels. The caveat is a jittery link: if latency alone marks a gateway down, every long-lived connection (push notifications, calls, smart-home hubs) is cut each time. There, raise the gateway's Latency High Threshold before relying on Failover States: latency above it marks the gateway down whatever the group's trigger, and only a gateway marked down has its states killed. Between the low and high thresholds, a group trigger of Member Down or Packet Loss keeps a delay alone from failing the group over. For the WANs underneath, WAN Failover holds a lossy WAN out until it is clean and moves connections back once it is.

DNS

The tunnel carries traffic; where DNS goes is a separate design decision, and there is no single correct answer. The plugin ignores the config file's DNS line and changes nothing about resolution. The common choices:

← Back to Create