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.
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
| Setting | pfSense (branch) | VPN server |
|---|---|---|
| Public IP / IKE identity | 198.51.100.20 | 203.0.113.10 |
| Protected networks | 192.168.10.0/24 | 10.10.0.0/16 |
| IKE version | IKEv2 | IKEv2 |
| IKE proposal | AES 256, SHA256, DH 20 | AES-256-CBC, SHA-256, DH group 20 |
| IKE lifetime | 28800 s | 28800 s |
| ESP proposal | AES256-GCM, PFS 20 | AES-256-GCM, PFS group 20 |
| Child SA lifetime | 3600 s | 3600 s |
| Authentication | Mutual PSK | Same pre-shared key |
| Dead peer detection | On | On |
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)
| Field | Value |
|---|---|
| Description | VPN server |
| Key Exchange version | IKEv2 |
| Internet Protocol | IPv4 |
| Interface | WAN |
| Remote Gateway | 203.0.113.10 |
| Authentication Method | Mutual PSK |
| My identifier | IP address: 198.51.100.20 (or My IP address if the WAN has the public IP) |
| Peer identifier | Peer IP address (resolves to 203.0.113.10) |
| Pre-Shared Key | <pre-shared-key> |
| Encryption Algorithm | AES, key length 256 bits; Hash SHA256; DH group 20 (nist ecp384) |
| Life Time | 28800 |
| Rekey Time / Reauth Time / Rand Time | Leave empty (derived from Life Time) |
| Child SA Start Action | Default (or Initiate at Start, see below) |
| Child SA Close Action | Restart/Reconnect |
| MOBIKE | Disable |
| Dead Peer Detection | Enabled, 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)
| Field | Value |
|---|---|
| Description | LAN to VPN server networks |
| Mode | Tunnel IPv4 |
| Local Network | LAN subnet (192.168.10.0/24) |
| NAT/BINAT translation | None |
| Remote Network | Network: 10.10.0.0 / 16 |
| Protocol | ESP |
| Encryption Algorithms | AES256-GCM, 128 bits (uncheck everything else) |
| Hash Algorithms | None selected (GCM provides integrity) |
| PFS key group | 20 (nist ecp384) |
| Life Time | 3600 |
| Automatically ping host | 10.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:
| Field | Value |
|---|---|
| Action | Pass |
| Interface | IPsec |
| Protocol | Any (or only what the server networks need) |
| Source | Network 10.10.0.0/16 |
| Destination | LAN 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:
- Under Interfaces > Assignments, add the new
ipsecinterface, enable it and, if needed, set its MSS. - 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.
- 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.