OPNsenseLab
Advanced

OPNsense High Availability with CARP: Active-Passive Failover Setup

Configure OPNsense HA using CARP virtual IPs and pfsync state synchronization for sub-second firewall failover — step-by-step for a two-node homelab or small office setup.

By OPNsenseLab Editorial · · 8 min read

OPNsense supports active-passive HA using CARP (Common Address Redundancy Protocol) for virtual IPs and pfsync for connection state synchronization. When the primary node fails, the secondary takes over in under a second with existing TCP sessions intact.

Architecture

ISP → [CARP VIP on WAN] → Primary OPNsense ←→ pfsync ←→ Secondary OPNsense

                           [CARP VIP on LAN] → Managed Switch → LAN

Both nodes have:

Hardware

Two identical or compatible units. Common homelab pairs:

The sync interface needs at least a direct crossover cable or a dedicated switch port between the nodes.

Step 1: Network addressing plan

NodeWAN IPLAN IPSYNC IP
Primary203.0.113.2/30192.168.1.2/24172.16.0.1/30
Secondary203.0.113.3/30192.168.1.3/24172.16.0.2/30
CARP VIP WAN203.0.113.4
CARP VIP LAN192.168.1.1

Step 2: Configure the primary node

Create CARP virtual IPs

Interfaces → Virtual IPs → Add:

Repeat for LAN CARP VIP.

Enable pfsync

Interfaces → Assignments → add the SYNC interface. Then:

System → High Availability → Settings:

Configure firewall rule for pfsync traffic

On the SYNC interface, allow pfsync protocol from 172.16.0.2.

Step 3: Configure the secondary node

Mirror the interface configuration with the secondary IPs. In HA settings:

Enable XMLSync to push config changes from primary to secondary: System → High Availability → Settings → Synchronize config to IP: 172.16.0.2

Step 4: Verify failover

# On a LAN client, ping the CARP LAN VIP continuously
ping 192.168.1.1

# Reboot the primary
# Observe: ping continues after ~1 second gap
# Secondary takes over the CARP VIP

Check System → High Availability → Status on both nodes to confirm MASTER/BACKUP state.

Common pitfalls

Coming from pfSense? pfSenseLab has a CARP comparison between OPNsense and pfSense implementations.

#opnsense #ha #carp #failover #high-availability #pfsync

Related

Comments