pfSense IPsec VPN: site-to-site example configuration

The Phase 1 and Phase 2 settings, firewall rules and MSS clamping for an IKEv2 site-to-site tunnel from pfSense to an IPsec VPN server, field by field.

pfSense198.51.100.20IPsec VPN server203.0.113.10VPN › IPsec › TunnelsPhase 1 IKEv2 · AES-256 · SHA256 · DH group 20 Remote gateway 203.0.113.10Phase 2 ESP AES-256-GCM · PFS group 20

The short answer

A pfSense IPsec VPN is configured under VPN > IPsec > Tunnels: one Phase 1 entry for the IKE SA (peer address, IKE version, authentication, IKE proposal) and one or more Phase 2 entries for the networks it protects (ESP proposal, PFS, lifetime). Traffic arriving from the tunnel is filtered on the Firewall > Rules > IPsec tab, tunnel state is under Status > IPsec, and TCP MSS clamping for IPsec is a single setting under System > Advanced > Firewall & NAT.

This guide is a complete pfSense site-to-site VPN example configuration for a branch firewall at 198.51.100.20 (LAN 192.168.10.0/24) connecting to an IPsec VPN server at 203.0.113.10 (networks 10.10.0.0/16) over IKEv2. Field names follow pfSense CE 2.7.x and pfSense Plus 24.x; labels can shift slightly between releases, so check the Netgate documentation for your version.

Values that must match on both sides

SettingpfSense (branch)VPN server
Public IP / IKE identity198.51.100.20203.0.113.10
Protected networks192.168.10.0/2410.10.0.0/16
IKE versionIKEv2IKEv2
IKE proposalAES 256, SHA256, DH 20AES-256-CBC, SHA-256, DH group 20
IKE lifetime28800 s28800 s
ESP proposalAES256-GCM, PFS 20AES-256-GCM, PFS group 20
Child SA lifetime3600 s3600 s
AuthenticationMutual PSKSame pre-shared key
Dead peer detectionOnOn

pfSense also offers AES-GCM for Phase 1. This example uses AES-256-CBC with SHA-256 for IKE because it matches the widest range of servers; switch both sides to GCM if you prefer. If you are still deciding on the IKE version, read IKEv1 or IKEv2 first.

Example pfSense site-to-site VPN configuration

The tables below are an example configuration for a pfSense firewall. Fields not listed can stay at their defaults.

Phase 1 (VPN > IPsec > Tunnels > Add P1)

FieldValue
DescriptionVPN server
Key Exchange versionIKEv2
Internet ProtocolIPv4
InterfaceWAN
Remote Gateway203.0.113.10
Authentication MethodMutual PSK
My identifierIP address: 198.51.100.20 (or My IP address if the WAN has the public IP)
Peer identifierPeer IP address (resolves to 203.0.113.10)
Pre-Shared Key<pre-shared-key>
Encryption AlgorithmAES, key length 256 bits; Hash SHA256; DH group 20 (nist ecp384)
Life Time28800
Rekey Time / Reauth Time / Rand TimeLeave empty (derived from Life Time)
Child SA Start ActionDefault (or Initiate at Start, see below)
Child SA Close ActionRestart/Reconnect
MOBIKEDisable
Dead Peer DetectionEnabled, Delay 10

Generate a long random pre-shared key (32 characters or more) and paste the same value on the VPN server. pfSense can generate one for you with the button next to the Pre-Shared Key field.

On the identifier: by default pfSense presents its WAN address. If the firewall sits behind another router, that is a private address, and the server will reject it. Set My identifier explicitly to the public IP (or another ID the server expects) in that case. In the encryption algorithm list, pfSense allows several entries; keep a single one so it is obvious which proposal will be used.

Phase 2 (Show Phase 2 Entries > Add P2)

FieldValue
DescriptionLAN to VPN server networks
ModeTunnel IPv4
Local NetworkLAN subnet (192.168.10.0/24)
NAT/BINAT translationNone
Remote NetworkNetwork: 10.10.0.0 / 16
ProtocolESP
Encryption AlgorithmsAES256-GCM, 128 bits (uncheck everything else)
Hash AlgorithmsNone selected (GCM provides integrity)
PFS key group20 (nist ecp384)
Life Time3600
Automatically ping host10.10.0.1 (optional, any host on the far side that answers ping)

The "128 bits" next to AES256-GCM is the length of the GCM integrity check value, not the key; the key is 256 bits. Add one Phase 2 entry per pair of networks if either side has more than one prefix. Save, then click Apply Changes.

Firewall rules for tunnel traffic

Traffic coming out of the tunnel is filtered on Firewall > Rules > IPsec, which is empty (deny) by default. Example rule:

FieldValue
ActionPass
InterfaceIPsec
ProtocolAny (or only what the server networks need)
SourceNetwork 10.10.0.0/16
DestinationLAN subnets

Outbound traffic from the LAN is covered by the default LAN rule. When an IPsec Phase 1 is enabled, pfSense adds the WAN rules for IKE, NAT-T and ESP from the remote gateway automatically, so you don't need manual WAN rules for the tunnel itself. In a typical setup outbound NAT doesn't interfere with tunnel-mode traffic; if you use manual outbound NAT rules, make sure none of them translates traffic from 192.168.10.0/24 to 10.10.0.0/16.

MSS clamping

Go to System > Advanced > Firewall & NAT, enable MSS Clamping and set Maximum MSS. The default is 1400; 1360 is a safer value with AES-GCM and NAT-T, and lower still on PPPoE. It applies to TCP flows crossing IPsec tunnels. For a route-based (VTI) tunnel, set the MSS on the assigned IPsec interface instead (see below).

Route-based option: Routed (VTI)

pfSense also supports route-based IPsec. Set the Phase 2 Mode to Routed (VTI), with Local Network 169.254.100.2/30 and Remote Network 169.254.100.1 (the server's inside address). Then:

  1. Under Interfaces > Assignments, add the new ipsec interface, enable it and, if needed, set its MSS.
  2. Add a static route to 10.10.0.0/16 via a gateway at 169.254.100.1 on that interface, or run BGP/OSPF with the FRR package.
  3. Set the Phase 1 Child SA Start Action to Initiate at Start, so the tunnel is up before traffic needs it.

The server must be configured route-based with matching inside addresses. Filtering for VTI traffic depends on the IPsec Filter Mode under VPN > IPsec > Advanced Settings; check your version's documentation for which tab the rules go on. The trade-offs are covered in the IPsec configuration examples hub.

Verify the tunnel

Open Status > IPsec. The Overview tab lists the Phase 1 with its state; click Connect P1 and P2s if it isn't up yet (or ping a host on 10.10.0.0/16 from the LAN). Good looks like:

  • Phase 1 shows Established with the remote host 203.0.113.10 and the algorithms you set.
  • Expanding the child SAs shows Installed, local 192.168.10.0/24, remote 10.10.0.0/16, and byte counters in both directions.
  • The SADs and SPDs tabs show one SA and one policy per direction.

From Diagnostics > Command Prompt or an SSH shell you can use the strongSwan tools directly:

# On the pfSense shell (example)
swanctl --list-sas        # IKE SA ESTABLISHED, CHILD_SA INSTALLED, counters
swanctl --list-conns      # the generated connection definitions
ping -S 192.168.10.1 10.10.0.1   # source the ping from the LAN address

# Logs: Status > System Logs > IPsec, or
tail -f /var/log/ipsec.log

Raise the log level under VPN > IPsec > Advanced Settings > IPsec Logging Controls (IKE SA, IKE Child SA, Configuration Backend) while debugging, then set it back.

Common problems

Proposal mismatch

NO_PROPOSAL_CHOSEN in the IPsec log means no common algorithm set. Check the Phase 1 encryption, hash and DH group against the server's IKE settings, and the Phase 2 algorithm and PFS key group against its ESP settings. A leftover second entry in Phase 2 (AES-CBC with SHA1, for example) doesn't cause a failure, but it can hide what was actually negotiated.

ID mismatch

AUTHENTICATION_FAILED or a peer config not found usually means the identifiers differ, or the key does. Behind NAT, set My identifier to what the server expects. On the server, the peer ID must match exactly, including type (IP address vs. FQDN).

NAT

If the firewall is behind another NAT device, NAT-T switches to UDP 4500 automatically; make sure UDP 500 and 4500 are forwarded or allowed upstream. If the tunnel is up but nothing returns, check the server has a route back to 192.168.10.0/24 and isn't translating it, and that the IPsec tab has a pass rule.

MTU and MSS

Ping works, web pages and file copies hang: enable MSS clamping as above, or lower the value. Test with ping -D -s 1372 10.10.0.1 (don't-fragment set) from the shell to find what passes. More steps in IPsec troubleshooting.

Running the other end

pfSense is a solid branch firewall; the other end still needs a server with a static public IP that every site can reach. TunnelYard gives you a dedicated IPsec server with its own static IP, ready in 10–15 minutes, with guided tunnel setup, presets per remote device and a peer config export for pfSense. Your offices' internet traffic then leaves from its static IP. Compare the same tunnel on MikroTik and strongSwan.

FAQ

pfSense IPsec VPN: common questions

Why does pfSense show AES256-GCM with 128 bits in Phase 2?

The 128 bits next to AES256-GCM is the length of the GCM integrity check value, not the key; the key is 256 bits. Select only AES256-GCM with 128 bits, leave the Hash Algorithms empty because GCM provides integrity, and set the PFS key group to 20 (nist ecp384) to match a server using AES-256-GCM with PFS group 20.

Do I need firewall rules for a pfSense IPsec tunnel?

Yes, on Firewall > Rules > IPsec, which is empty and therefore denies by default. Add a pass rule from the remote networks, such as 10.10.0.0/16, to your LAN subnets. Outbound LAN traffic is covered by the default LAN rule, and when a Phase 1 is enabled pfSense adds the WAN rules for IKE, NAT-T and ESP from the remote gateway automatically.

How do I enable MSS clamping for IPsec on pfSense?

Go to System > Advanced > Firewall & NAT, enable MSS Clamping and set Maximum MSS. The default is 1400; 1360 is a safer value with AES-GCM and NAT-T, and lower still on PPPoE. It applies to TCP flows crossing IPsec tunnels. For a Routed (VTI) tunnel, set the MSS on the assigned IPsec interface instead.

Does pfSense support route-based IPsec with VTI?

Yes. Set the Phase 2 Mode to Routed (VTI) with local 169.254.100.2/30 and remote 169.254.100.1, assign and enable the new ipsec interface, and add a static route to the remote networks via 169.254.100.1, or run BGP or OSPF with the FRR package. Set Child SA Start Action to Initiate at Start. The server must be route-based with matching inside addresses.

Why does pfSense IPsec fail with AUTHENTICATION_FAILED behind NAT?

By default pfSense presents its WAN address as its identifier. Behind another router that is a private address, so the server rejects it. Set My identifier in Phase 1 to the public IP, or another ID the server expects; the peer ID on the server must match exactly, including type (IP address or FQDN). A wrong pre-shared key gives the same error, so check both.

Where can I see pfSense IPsec tunnel status and logs?

Open Status > IPsec: Phase 1 should show Established and the child SAs Installed with byte counters in both directions. Logs are under Status > System Logs > IPsec. From a shell, pfSense runs strongSwan underneath, so swanctl --list-sas and tail -f /var/log/ipsec.log work too. See IPsec troubleshooting for a full checklist.