OPNsenseXXVIII · pfsync and Configuration SynchronisationState and configuration synchronisation
pfsync configuration on OPNsense
What you'll learn
- Configure the sync interface with a private subnet
- Set up pfsync on the sync interface
- Verify replication with a live connection test
- Troubleshoot the most common pfsync configuration errors
Prerequisites
Verified against OPNsense 25.x · FreeBSD 14.x · PF (FreeBSD packet filter) FreeBSD 14.x · Unbound 1.20+ · Kea DHCP OPNsense 25.x plugin · WireGuard in-kernel + OPNsense plugin · strongSwan (IPsec plugin) OPNsense 25.x plugin · OpenVPN 2.6.x · Suricata 7.x · 2026-08-14
Configuring pfsync correctly is the difference between an HA pair that survives failover and one that drops every connection. This lesson walks through the configuration step by step.
The sync interface
The sync interface is a dedicated physical or virtual interface between the two firewalls. It is not on any production VLAN. It carries only pfsync traffic (and optionally the configuration synchronisation traffic).
The address scheme is typically a /30 from a documentation range:
FW-A sync: 10.99.0.1/30
FW-B sync: 10.99.0.2/30
A /30 has exactly two usable addresses — one for each firewall. This is the cleanest possible design: nothing else can have an address on this segment.
Configuring the sync interface on OPNsense
The sync interface is configured like any other interface:
- Assign a physical interface (e.g.,
ix1) underInterfaces → Assignments. - Give it a static IP (
10.99.0.1/30on FW-A,10.99.0.2/30on FW-B). - Add a pass rule on the sync interface for protocol PFSYNC, source the peer’s sync address, destination this node’s sync address. pfsync has no port — it is its own IP protocol, number 240 — so the rule selects a protocol, not a port. Add the mirror-image rule on the other node.
- Do not add firewall rules that allow production traffic. The sync interface should be reachable only by pfsync and config sync.
- Block everything else with an explicit
Block any → anyrule.
$ ifconfig pfsync0pfsync0: flags=0<> metric 0 mtu 1500
groups: pfsync
syncdev: ix1 syncpeer: 10.99.0.2 maxupd: 128 defer: off
syncok: 1Illustrative output
Configuring pfsync
Under System → High Availability → Settings:
- Synchronize all states via: the sync interface (e.g.,
ix1or the OPT interface assigned to the sync network). Leaving this unset disables state synchronisation entirely. - Synchronize peer IP: the other node’s sync IP. Left
blank, pfsync uses the multicast group
224.0.0.240on the sync interface instead. - Sync compatibility: the pfsync protocol version both nodes should speak. It matters during a rolling upgrade, when the two nodes are briefly on different releases.
Save the configuration. The pfsync0 virtual interface comes up. State replication begins.
Verifying replication
The verification is on both nodes:
- On FW-A, run
pfctl -s state | wc -l. Note the count. - On FW-B, run the same command. The count should be within 1% of FW-A’s.
- Open a new connection (e.g.,
curl https://192.0.2.10) from a LAN host. The state for that connection appears on FW-A. - Within a fraction of a second, the same state appears on FW-B.
pfctl -s state prints addresses, never hostnames, so grep for
the server’s IP rather than its DNS name:
$ pfctl -s state | grep -c '192.0.2.10:443'1Illustrative output
If FW-B shows 0 where FW-A shows the entry, or if the totals from step 2 diverge and stay diverged, replication is broken.
Common misconfigurations
The most common pfsync mistakes:
- Sync interface on the production data path. pfsync will work, but the security model is broken — anyone on that path can inject pfsync packets.
- Peer IP is wrong. Replication silently fails. The symptom is divergence of state counts after a few minutes.
- Sync interface is firewalled and blocks pfsync. The rules on the sync interface must pass IP protocol pfsync (240) between the two sync addresses, in both directions. Operators who look for a port to open find nothing, because pfsync has no port.
- MTU mismatch. If the sync interface has a smaller MTU than the rest, large pfsync packets will fragment and may be dropped. Set MTU explicitly.
- Multicast routing. If the sync interface is on a shared switch with multiple segments, ensure multicast is not blocked between the segments.
Knowledge check · 3 questions
Q1. CARP works between two OPNsense nodes but pfsync replication does not. The state counts diverge within minutes. What is the first thing to check?
Q2. Putting the sync interface on a VLAN that also carries production traffic is acceptable as long as the firewall blocks production traffic from reaching the sync IP.
Q3. Which of the following are common pfsync misconfigurations? Select all that apply.
Passing score: 75%. Answers are checked in this browser.