A site to site IPsec VPN connects two distinct networks across the internet securely, allowing hosts on both sides to communicate as if they were on the same local network.
In this post, we will walk through configuring a policy based site to site IPsec VPN on pfSense using IKEv2, configuring Phase 1 and Phase 2 parameters, setting up firewall rules, and handling multi subnet or VLAN routing.
Phase 1 Configuration
Phase 1 establishes the secure, encrypted channel (IKE SA) between the two pfSense firewalls.
- Navigate to VPN > IPsec > Tunnels.
- Click Add P1 and configure the following:
- Key Exchange Version:
IKEv2(if both sides support it) - Internet Protocol:
IPv4 - Interface:
WAN - Remote Gateway: Remote public IP address (e.g.,
10.20.20.2) - Description: Enter a descriptive identifier
- Authentication Method:
Mutual PSK - My Identifier:
IP address - Peer Identifier:
IP address - Pre-Shared Key: Enter your pre shared key string
- Encryption Algorithm:
AES128-bit, Hash:SHA256, DH Group:14 (2048 bit) - Lifetime:
28800seconds
- Key Exchange Version:
- Click Save and Apply Changes.
Both endpoints must have matching Phase 1 proposal parameters for negotiation to succeed.
Phase 2 Configuration
Phase 2 establishes the IPsec Security Association (IPsec SA) that encrypts and routes traffic between specific subnets.
- On VPN > IPsec > Tunnels, click Show Phase 2 Entries under your Phase 1 entry.
- Click Add P2 and configure:
- Mode:
Tunnel IPv4 - Local Network:
LAN Subnet(or specify your local network CIDR, e.g.,192.168.1.0/24) - NAT Configuration:
None - Remote Network:
Network(enter remote subnet CIDR, e.g.,192.168.2.0/24) - Protocol:
ESP - Encryption Algorithm:
AES 128-bit - Hash Algorithm:
SHA256 - PFS Key Group:
14 - Lifetime:
3600seconds
- Mode:
- Click Save and Apply Changes.
Configuring Firewall Rules
By default, pfSense blocks all incoming traffic on the IPsec interface. Even if Phase 1 and Phase 2 negotiate successfully, traffic will be dropped unless explicit firewall rules are created.
- Navigate to Firewall > Rules > IPsec.
- Click Add to create a rule:
- Action:
Pass - Interface:
IPsec - Address Family:
IPv4 - Protocol:
Any - Source:
Any(or specify your remote subnet for tighter security) - Destination:
Any(or specify your local subnet)
- Action:
- Click Save and Apply Changes on both firewalls.
Ensure Phase 1, Phase 2, and Firewall rules are configured on both pfSense nodes, with inverted local and remote network settings on the peer firewall.
Handling Multiple Subnets or VLANs
Policy based IPsec requires a dedicated Phase 2 entry for every local and remote subnet combination. If you have an additional VLAN (e.g., 192.168.10.0/24) on one side that needs access through the tunnel:
- On the local firewall, go to VPN > IPsec > Tunnels and expand Show Phase 2 Entries.
- Click Add P2:
- Local Network: Select
Networkand enter your VLAN subnet (192.168.10.0/24). - Remote Network: Select
Networkand enter the remote network IP (192.168.2.0/24). - Match the Encryption, Hash, and PFS settings with your previous P2 entry.
- Local Network: Select
- On the remote firewall, add a corresponding Phase 2 entry:
- Local Network:
LAN Subnet(192.168.2.0/24). - Remote Network: Select
Networkand enter the local VLAN subnet (192.168.10.0/24).
- Local Network:
If a Phase 2 entry exists on one side without a matching entry on the remote peer, traffic for that subnet will fail to negotiate or route across the tunnel.
Verifying Tunnel Status
To check the IPsec status and connect:
- Navigate to Status > IPsec.
- Check the Phase 1 and Phase 2 status.
- Click Connect VPN if the tunnel is down.
- Verify end-to-end connectivity using ping from a local client:
ping 192.168.2.10