pfSense
This tutorial explains how to set up a policy-based or route-based IPsec VPN with a pfSense device.
(Policy-based only) LAN interface configuration
- From the pfSense WebGUI, select Interfaces > LAN.
- Choose an interface from the Available network ports list.
- Select Add. The General Configuration dialog displays.
Refer to the image below for guidance on which values to use.
![General configuration dialog for interface setup for a policy based configuration](/assets/pfsense-interface-config_hu79adb1e35489ffe2422b0d69c65d0d82_92709_1156x582_resize_q75_box_3-a7254eed.png)
Field | Value |
---|
Enable | ✔️ Enable interface |
Description | LAN |
IPv4 Configuration Type | Static IPv4 |
IPv6 Configuration Type | Static IPv6 |
MSS | 1446 |
Phase 1
Policy-based configuration
![pfSense IPsec phase 1 setting values for a policy based configuration](/assets/pfsense-p1-settings_hua72739a00edddea1dd17bb209767fcd0_116200_1160x820_resize_q75_box_3-f415947b.png)
Field | Value |
---|
Description | Name |
Key Exchange Version | IKE v2 |
Internet Protocol | IPv4 |
Interface | WAN |
Remote Gateway | <Anycast IP provided by Cloudflare> |
![pfSense IPsec phase 1 expiration and replacement values for a policy based configuration](/assets/pfsense-p1-expiration-replacement_hu3205985a9015f6224086ca6ea17dd10f_96794_1188x442_resize_q75_box_3-bc2c6d39.png)
Field | Value |
---|
Life Time | 28800 |
Rekey Time | 14400 |
Reauth Time | 0 |
Route-based configuration
![pfSense IPsec phase 1 setting values for a route based configuration](/assets/pfsense-p1-settings_hua72739a00edddea1dd17bb209767fcd0_116200_1160x820_resize_q75_box_3-f415947b.png)
Field | Value |
---|
Description | Name |
Key Exchange Version | IKE v2 |
Internet Protocol | IPv4 |
Interface | WAN |
Remote Gateway | <Anycast IP provided by Cloudflare> |
![pfSense IPsec phase 1 expiration and replacement values for a route based configuration](/assets/pfsense-p1-expiration-replacement_hu3205985a9015f6224086ca6ea17dd10f_96794_1188x442_resize_q75_box_3-bc2c6d39.png)
Field | Value |
---|
Life Time | 28800 |
Rekey Time | 14400 |
Reauth Time | 0 |
Phase 2
Policy-based configuration
![pfSense IPsec phase 2 general information values](/assets/pfsense-p2-general-info_hu727edce65ddbbc17a71424a8950fc5b5_71632_1165x615_resize_q75_box_3-849888af.png)
Field | Value |
---|
Description | Name |
Mode | Tunnel IPv4 |
Local Network | <Local Network to be tunneled> |
NAT/BINAT translation | None |
Remote Network | Remote network available via the tunnel |
![pfSense IPsec phase 2 key exchange values](/assets/pfsense-p2-key-exchange_hu756987d1f257627fce8ba3e810ec41aa_76373_1163x610_resize_q75_box_3-8af9e2eb.png)
Field | Value |
---|
Protocol | ESP |
Encryption Algorithm | ✔️ AES128-GCM, 128 bits |
PFS key group | 14 (2048 bit) |
![pfSense IPsec phase 2 key exchange values](/assets/pfsense-p2-expiration-replacement_hu0b07888915df409ff8cae3a4c9d939e2_113595_1169x597_resize_q75_box_3-e1873a49.png)
Field | Value |
---|
Life Time | 3600 |
Rekey Time | 3240 |
Rand Time | 360 |
Automatically ping host | Specify an IP address available via the tunnel. Refer to the Description field for more information. |
Route-based configuration
![pfSense IPsec phase 2 general information for a route based configuration](/assets/pfsense-p2-general-info-route-based_hub19035cad1c540cc51e9b159ea8d03e8_31611_1154x282_resize_q75_box_3-b67bf004.png)
![pfSense IPsec phase 2 network settings for a route based configuration](/assets/pfsense-p2-networks-route-based_hu658d111d806b76dcf6b5de567a888895_30644_1153x229_resize_q75_box_3-754721a7.png)
Field | Value |
---|
Description | Name |
Mode | Routed (VTI) |
Local Network | <Local Tunnel Inside IP> |
Remote Network | <Remote Tunnel Inside IP> |
![pfSense IPsec phase 2 key exchange values for a route based configuration](/assets/pfsense-p2-key-exchange_hu756987d1f257627fce8ba3e810ec41aa_76373_1163x610_resize_q75_box_3-8af9e2eb.png)
Field | Value |
---|
Protocol | ESP |
Encryption Algorithm | ✔️ AES128-GCM, 128 bits |
PFS key group | 14 (2048 bit) |
![pfSense IPsec phase 2 key exchange values](/assets/pfsense-p2-expiration-replacement_hu0b07888915df409ff8cae3a4c9d939e2_113595_1169x597_resize_q75_box_3-e1873a49.png)
Field | Value |
---|
Life Time | 3600 |
Rekey Time | 3240 |
Rand Time | 360 |
Automatically ping host | Specify an IP address available via the tunnel. Refer to the Description field for more information. |
(Route-based only) Interface assignment
- From the pfSense WebGUI, select Interfaces > LAN.
- Choose an interface from the Available network ports list.
- Select Add. The General Configuration dialog displays.
Refer to the image below for guidance on which values to use.
![General configuration dialog for interface setup for a policy based configuration](/assets/pfsense-interface-config_hu79adb1e35489ffe2422b0d69c65d0d82_92709_1156x582_resize_q75_box_3-a7254eed.png)
Field | Value |
---|
Enable | ✔️ Enable interface |
Description | LAN |
IPv4 Configuration Type | Static IPv4 |
IPv6 Configuration Type | Static IPv6 |
MSS | 1446 |
- From the pfSense WebGUI, select Interfaces > Assignments.
![pfSense interface assignment settings for route based configuration](/assets/pfsense-interface-config-add-ipsec_hud69d47b2d26e7e65e5ffe1cf7cd86001_43139_1167x352_resize_q75_box_3-0328df05.png)
- From Available network ports, select + Add.
![Adding an interface to a pfSense interface assignment with a route based configuration](/assets/pfsense-interface-config-opt1_hufffd389cfb3b647760b16f2b3d57d598_45348_1209x437_resize_q75_box_3-21b1c22c.png)
- Under Interface, select OPT1.
![pfSense interface general configuration settings for a route based configuration](/assets/pfsense-interface-config-opt1-settings_hud03c3aef822d0252388a28cafef5f45b_134275_1207x785_resize_q75_box_3-291defa7.png)
- Ensure Enable interface is selected.
- For Description, add a description to help you identify the interface.
- For MSS, enter 1446, which should be the same as the LAN interface.
- Select Save to save your changes when you are done.
Routing configuration
- From the pfSense WebGUI, select System, Routing, Static Routes.
- On the Static Routes page, select Add.
- Create static routes for all network that will be routed via the tunnel with Gateway as the IPsec VTI interface.
![pfSense interface routing configuration settings for a route based configuration](/assets/pfsense-interface-config-routing-config_hub1c24e659e9a267d1a7a4f9142d9a68d_54764_1174x457_resize_q75_box_3-26cbfa61.png)
Firewall configuration
- From the pfSense WebGUI, select Firewall Rules.
- Select LAN.
- Ensure a rule exists that allows traffic from LAN to IPsec.
- Select Save when you are done.
If you need to allow traffic from IPsec to LAN, you will need to create rules that allow this.