Skip to content

Nuface Blog

้šจๆ„้šจๆ‰‹่จ˜ Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

OPNsense High Availability with CARP โ€” Overview and Setup Guide

Posted on 2025-11-122025-11-12 by Rico

๐Ÿงญ 1. What is CARP?

CARP (Common Address Redundancy Protocol) allows multiple firewalls to share a virtual IP address so that if one device fails, another automatically takes over.
This ensures continuous network availability and seamless failover.

In OPNsense, a typical HA setup includes:

  • Master firewall (active)
  • Backup firewall (standby)

When the master stops responding, the backup promotes itself to master and assumes the shared VIP.


โš™๏ธ 2. How It Works

๐Ÿ”น Virtual IP

CARP creates a shared IP (e.g. 203.66.10.10) visible to the outside world.
Traffic is always directed to this VIP, regardless of which node is active.

DeviceReal IPRole
FW-A203.66.10.11Master
FW-B203.66.10.12Backup
Shared203.66.10.10CARP VIP

๐Ÿ”น VHID & AdvSkew

  • VHID = Unique group identifier for each CARP VIP.
  • AdvSkew = Priority value ( lower = higher priority ).
HostAdvSkewRole
FW-A0Master
FW-B100Backup

๐Ÿ”น Heartbeat (pfsync + CARP)

CARP sends multicast heartbeats between members.
If the backup stops receiving heartbeats, it immediately takes control of the VIP.
pfsync is used to replicate connection state tables, ensuring sessions continue after failover.


๐Ÿงฉ 3. Typical Topology

[Internet]
   โ”‚
   โ–ผ
Virtual IP 203.66.10.10 (CARP)
   โ”‚
 โ”œโ”€ FW-A Master (203.66.10.11)
 โ””โ”€ FW-B Backup (203.66.10.12)
   โ”‚
[LAN Switch] โ†’ 192.168.100.0/24

If FW-A fails, FW-B becomes master within seconds, and users remain online.


๐Ÿงฐ 4. Setup Steps

Step 1 โ€“ Sync Interface

Create a dedicated SYNC interface:

FW-A โ†’ 10.0.0.1
FW-B โ†’ 10.0.0.2

Prefer direct link or isolated VLAN.


Step 2 โ€“ Enable pfsync

System โ†’ High Availability โ†’ Settings

  • Enable pfsync
  • Select SYNC interface

Step 3 โ€“ Add CARP Virtual IP

Firewall โ†’ Virtual IPs โ†’ Add

  • Type: CARP
  • Interface: WAN
  • VIP: 203.66.10.10/24
  • VHID: 1
  • Password: shared secret
  • AdvSkew: 0 (master), 100 (backup)

Step 4 โ€“ (Option) Enable XMLRPC Config Sync

System โ†’ High Availability โ†’ Settings โ†’ XMLRPC Sync

  • Specify peer IP
  • Enable desired sync sections (e.g. Firewall rules, Aliases)

Step 5 โ€“ Test Failover

  1. Disable or unplug FW-Aโ€™s WAN.
  2. Within ~3 seconds, FW-B assumes the VIP.
  3. Active sessions continue without interruption.

โœ… 5. Best Practices

ItemRecommendation
Heartbeat LinkUse dedicated VLAN or cable for SYNC
VHIDUnique per CARP group
AdvSkewMaster = 0โ€“10 / Backup = 50โ€“100
pfsyncUse internal network / not filtered
ValidationAlways simulate failover tests

๐Ÿ’ก 6. Common Use Cases

  • Dual-firewall redundancy (WAN or LAN)
  • Shared public service IPs
  • Data center edge firewall failover

โœ… 7. Conclusion

CARP is the foundation of OPNsense High Availability.
By pairing two firewalls with shared Virtual IPs and state synchronization,
you gain redundancy and seamless failover without manual intervention.

Combined with pfsync and XMLRPC config sync, CARP provides enterprise-grade resilience for mission-critical network environments.

Recent Posts

  • Postfix + Letโ€™s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Letโ€™s Encrypt + BIND9 + DANE TLSA ๆŒ‡็ด‹่‡ชๅ‹•ๆ›ดๆ–ฐๅฎŒๆ•ดๆ•™ๅญธ
  • Deploying DANE in Postfix
  • ๅฆ‚ไฝ•ๅœจ Postfix ไธญ้ƒจ็ฝฒ DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme