IPsec IKEv2 Mobile VPN in pfSense - Remote Access Setup

IKEv2 (Internet Key Exchange version 2) is the most practical protocol for providing mobile users with VPN access to a corporate network through pfSense. The key advantage of IKEv2 over other remote access protocols is native support in all modern operating systems: Windows 10/11, macOS, iOS, and Android. Users do not need to install third-party VPN clients - connections are established using built-in operating system capabilities.

This guide covers the complete lifecycle of an IPsec IKEv2 configuration for mobile clients in pfSense: from certificate creation through client device setup. The material is intended for administrators familiar with the pfSense web interface and basic PKI concepts.

Advantages of IKEv2 for Remote Access

Before selecting a remote access protocol, it is worth evaluating the advantages of IKEv2 compared to the alternatives.

CharacteristicIKEv2OpenVPNWireGuard
Native OS supportWindows, macOS, iOS, AndroidNoNo
Connection speedUnder 1 second5-10 secondsUnder 1 second
MOBIKE supportYes (seamless Wi-Fi/LTE switching)NoYes
StandardizationRFC 7296ProprietaryNon-standard
AuthenticationCertificates, EAP-MSCHAPv2Certificates, passwordsPre-shared keys
NAT-TBuilt-inBuilt-in (UDP/TCP)Built-in

MOBIKE (IKEv2 Mobility and Multihoming Protocol, RFC 4555) allows a VPN connection to persist when the network interface changes - for example, when switching from Wi-Fi to a cellular network. For mobile users, this is a critically important feature.

Certificate Preparation

IKEv2 for mobile clients requires a public key infrastructure (PKI). Three types of certificates must be created: a root Certificate Authority (CA) certificate, a server certificate, and user certificates (when using certificate-based authentication).

Creating the Certificate Authority (CA)

Navigate to System > Cert. Manager > CAs and click Add.

FieldValueNotes
Descriptive NameIKEv2 VPN CAName to identify the CA
MethodCreate an internal Certificate AuthorityCreates a new CA
Key typeRSACompatible with all clients
Key length4096Minimum 2048 for production environments
Digest AlgorithmSHA256Standard hash algorithm
Lifetime365010 years, sufficient for a root CA
Common NameIKEv2 VPN CAUnique CA name
Country Code(your country code)Two-letter ISO 3166-1 code
State or Province(your region)Region name
City(your city)City name
Organization(your organization)Organization name

Click Save. The root CA certificate will be used to sign the server and user certificates.

Creating the Server Certificate

Navigate to System > Cert. Manager > Certificates and click Add/Sign.

FieldValueNotes
MethodCreate an internal CertificateCreates a new certificate
Descriptive NameIKEv2 VPN ServerName for identification
Certificate authorityIKEv2 VPN CAThe CA created in the previous step
Key typeRSACompatible with all clients
Key length2048Sufficient for a server certificate
Digest AlgorithmSHA256Standard algorithm
Lifetime825Apple limits server certificate validity to 825 days
Common Namevpn.example.comServer FQDN or public IP address
Certificate TypeServer CertificateServer certificate type

Warning:

The Alternative Names field must include a SAN (Subject Alternative Name) of type FQDN or IP Address matching the address clients connect to. Without a SAN, Windows and iOS clients will refuse to connect. If using an IP address, add a SAN of type IP Address; if using a domain name, add a SAN of type FQDN.

Warning:

Apple devices (macOS, iOS) reject server certificates with a Lifetime exceeding 825 days. Exceeding this value will result in a certificate validation error during connection.

Creating User Certificates

User certificates are only required when using certificate-based authentication. When using EAP-MSCHAPv2 (username/password authentication), this step can be skipped.

For each user, navigate to System > Cert. Manager > Certificates and click Add/Sign.

FieldValueNotes
MethodCreate an internal CertificateCreates a new certificate
Descriptive Nameuser-smithUsername for identification
Certificate authorityIKEv2 VPN CAThe same CA
Key typeRSACompatible with all clients
Key length2048Sufficient for a user certificate
Digest AlgorithmSHA256Standard algorithm
Lifetime3651 year - recommended duration for user certificates
Common Nameuser-smithUnique user identifier
Certificate TypeUser CertificateUser certificate type

To export a user certificate in PKCS#12 (.p12) format, navigate to System > Cert. Manager > Certificates, locate the desired certificate, and click the PKCS#12 export icon. This file contains the certificate and private key, protected by a password.

Mobile Client Configuration

Mobile client settings are configured under VPN > IPsec > Mobile Clients.

Mobile Clients Tab

FieldValueNotes
Enable IPsec Mobile Client SupportCheckedActivates mobile client support
User AuthenticationLocal DatabaseLocal pfSense user database (or RADIUS)
Group Authentication(as needed)Group restriction
Virtual Address PoolProvide a virtual IP address to clientsAssigns IP addresses to clients
Network ListProvide a list of accessible networks to clientsSends network list for split tunnel

Virtual Address Pool

FieldValueNotes
Virtual Address Pool10.10.10.0/24Address pool for VPN clients

The pool subnet must not overlap with existing local subnets.

DNS Servers

FieldValueNotes
Provide a DNS server list to clientsCheckedPushes DNS servers to clients
DNS Server 110.1.0.1Local DNS server address
DNS Server 21.1.1.1Fallback public DNS

Click Save. pfSense will prompt you to create Phase 1 - click the link to proceed to configuration.

Phase 1 Configuration

Phase 1 for mobile clients is configured under VPN > IPsec > Tunnels. After saving the Mobile Clients settings, pfSense automatically creates a Phase 1 entry with the mobile type.

Phase 1 configuration for mobile clients

Fig. 1. Phase 1 configuration for mobile clients

General Information

FieldValueNotes
Key Exchange versionIKEv2Required for mobile clients
Internet ProtocolIPv4Or IPv6, depending on addressing
InterfaceWANInterface for accepting connections
DescriptionIKEv2 Mobile ClientsDescription for identification

Phase 1 Proposal - Authentication

FieldValueNotes
Authentication MethodEAP-MSCHAPv2Username/password authentication
My identifierDistinguished Name: vpn.example.comMust match CN or SAN of the server certificate
Peer identifierAnyMobile clients - identifier unknown in advance
My CertificateIKEv2 VPN ServerServer certificate created earlier
My Certificate AuthorityIKEv2 VPN CACA that signed the server certificate

When using certificate-based authentication instead of EAP-MSCHAPv2, select Authentication Method: Mutual RSA and specify the appropriate CA for validating client certificates.

Warning:

When using EAP-MSCHAPv2, users must be created in System > User Manager with passwords. These credentials are used to authenticate VPN connections.

Phase 1 Proposal - Encryption Algorithm

FieldValueNotes
AlgorithmAES-256-GCMAuthenticated encryption with hardware acceleration
Key Length256 bits (auto)With AES-GCM, key length is determined automatically
HashSHA256PRF (Pseudo-Random Function)
DH Group14 (2048 bit)Minimum recommended group

For compatibility with a broader range of clients, additional Encryption Algorithms may be added. Recommended set:

AlgorithmHashDH GroupNote
AES-256-GCMSHA25614Primary (Windows 10/11, macOS, iOS)
AES-256-CBCSHA25614Fallback (Android, older clients)

Expiration and Replacement

FieldValueNotes
Life Time288008 hours
Rekey Time(empty)Automatic calculation
Reauth Time(empty)Automatic calculation

Advanced Options

FieldValueNotes
NAT TraversalAutoAutomatic NAT detection
MOBIKEEnableSupport for network switching
Dead Peer DetectionEnabledDetect disconnected clients
DPD Delay30DPD interval in seconds
DPD Max Failures5Missed responses before disconnect

Warning:

MOBIKE must be enabled for mobile clients. Without MOBIKE, the VPN connection drops when switching networks (for example, when moving from Wi-Fi to LTE).

Phase 2 Configuration

After saving Phase 1, a Phase 2 entry must be created. Click Show Phase 2 Entries, then Add P2.

Phase 2 configuration for mobile clients

Fig. 2. Phase 2 configuration for mobile clients

General Information

FieldValueNotes
ModeTunnel IPv4Standard mode
Local NetworkLAN subnetOr a specific subnet: 10.1.0.0/24
NAT/BINATNoneNo address translation
DescriptionIKEv2 Mobile - LAN AccessPhase 2 description

When access to multiple subnets (LAN, DMZ, server network) is required, create a separate Phase 2 entry for each subnet.

Phase 2 Proposal

FieldValueNotes
ProtocolESPTraffic encryption and authentication
Encryption AlgorithmsAES-256-GCMMust match client capabilities
Hash AlgorithmsSHA256For compatibility with clients lacking GCM support
PFS key group14 (2048 bit)Perfect Forward Secrecy

Expiration and Replacement

FieldValueNotes
Life Time36001 hour
Rekey Time(empty)Automatic calculation

Firewall Rules

Two sets of firewall rules are required for IKEv2 VPN to function: on the WAN tab and the IPsec tab.

WAN Interface Rules

Inbound traffic for establishing IKE connections must be permitted on the WAN interface.

ActionProtocolSourceDestination PortDescription
PassUDPAny500IKE - key exchange
PassUDPAny4500NAT-T - ESP encapsulation in UDP

pfSense automatically creates rules for IKE traffic when IPsec tunnels are configured. However, when using floating rules or a non-standard firewall configuration, these rules may need to be added explicitly.

IPsec Tab Rules

The Firewall > Rules > IPsec tab controls traffic passing through the VPN tunnel. By default, all traffic is blocked.

Minimum rule set:

ActionProtocolSourceDestinationDescription
PassAny10.10.10.0/24LAN netAllow traffic from VPN pool to LAN
PassAny10.10.10.0/2410.10.10.0/24Allow traffic between VPN clients

In production environments, rules should be restricted to specific protocols and ports. For example, allow only DNS (UDP/TCP 53), RDP (TCP 3389), SSH (TCP 22), and HTTPS (TCP 443).

For more details on firewall rules, see pfSense Firewall Rules .

Client Configuration

Windows 10/11

Windows 10 and 11 support IKEv2 through the built-in VPN client. To connect, the CA certificate must be imported and a VPN connection created.

Importing the CA Certificate

  1. Export the CA certificate from pfSense: System > Cert. Manager > CAs - click the CA Certificate export icon.
  2. Copy the .crt file to the Windows computer.
  3. Double-click the .crt file.
  4. Click Install Certificate.
  5. Select Local Machine and click Next.
  6. Select Place all certificates in the following store and click Browse.
  7. Select Trusted Root Certification Authorities and click OK.
  8. Click Next, then Finish.

Warning:

The CA certificate must be installed in the Trusted Root Certification Authorities store of the computer (Local Machine), not the user (Current User). Otherwise, Windows will be unable to validate the server certificate.

Creating the VPN Connection

  1. Open Settings > Network & Internet > VPN.
  2. Click Add a VPN connection.
  3. Fill in the parameters:
FieldValue
VPN providerWindows (built-in)
Connection nameOffice VPN
Server name or addressvpn.example.com
VPN typeIKEv2
Type of sign-in infoUser name and password
User name(username from pfSense)
Password(user password)
  1. Click Save.
  2. To connect, click the VPN connection and click Connect.

Strengthening Security on Windows

By default, Windows may use weak encryption algorithms. To enforce strong algorithms, run the following in PowerShell as Administrator:

Set-VpnConnectionIPsecConfiguration -ConnectionName "Office VPN" `
    -AuthenticationTransformConstants GCMAES256 `
    -CipherTransformConstants GCMAES256 `
    -EncryptionMethod AES256 `
    -IntegrityCheckMethod SHA256 `
    -DHGroup Group14 `
    -PfsGroup PFS2048 `
    -Force

macOS

macOS supports IKEv2 through built-in capabilities. Configuration requires importing the CA certificate and creating a network profile.

Importing the CA Certificate

  1. Export the CA certificate from pfSense in .crt format.
  2. Open the file on macOS - Keychain Access will launch.
  3. Add the certificate to the System keychain.
  4. Double-click the added certificate.
  5. Under Trust, set When using this certificate to Always Trust.
  6. Close the window and enter the administrator password to confirm.

Creating the VPN Connection

  1. Open System Settings > VPN (macOS 13+) or System Preferences > Network (macOS 12 and earlier).
  2. Click Add VPN Configuration > IKEv2.
  3. Fill in the parameters:
FieldValue
Display NameOffice VPN
Server Addressvpn.example.com
Remote IDvpn.example.com
Local ID(leave empty)
User AuthenticationUsername
Username(username from pfSense)
Password(user password)
  1. Click Create.
  2. To connect, toggle the VPN connection switch.

iOS

iOS supports IKEv2 without installing additional applications.

Installing the CA Certificate Profile

  1. Export the CA certificate from pfSense.
  2. Transfer the .crt file to the device (via AirDrop, email, or a web server).
  3. Open the file on the device - a prompt to install the profile will appear.
  4. Navigate to Settings > General > VPN & Device Management.
  5. Tap the downloaded profile and tap Install.
  6. After installation, navigate to Settings > General > About > Certificate Trust Settings.
  7. Enable trust for the installed CA certificate.

Creating the VPN Connection

  1. Navigate to Settings > General > VPN & Device Management > VPN.
  2. Tap Add VPN Configuration.
  3. Fill in the parameters:
FieldValue
TypeIKEv2
DescriptionOffice VPN
Servervpn.example.com
Remote IDvpn.example.com
Local ID(leave empty)
User AuthenticationUsername
Username(username from pfSense)
Password(user password)
  1. Tap Done.
  2. To connect, toggle the VPN switch in Settings.

Android

Android supports IKEv2 natively starting from version 11 through the built-in VPN client. For earlier versions, the strongSwan VPN Client from Google Play is required.

Android 11 and Later (Built-in Client)

  1. Export the CA certificate from pfSense.
  2. Navigate to Settings > Security > Encryption & credentials > Install a certificate.
  3. Select CA certificate and install the .crt file.
  4. Navigate to Settings > Network & Internet > VPN.
  5. Tap + to add a new VPN profile.
  6. Fill in the parameters:
FieldValue
NameOffice VPN
TypeIKEv2/IPSec MSCHAPv2
Server addressvpn.example.com
IPSec identifier(leave empty)
IPSec CA certificate(select the installed CA)
Username(username from pfSense)
Password(user password)
  1. Tap Save.

strongSwan VPN Client (Android 10 and Earlier)

  1. Install strongSwan VPN Client from Google Play.
  2. Import the CA certificate through the application.
  3. Create a new VPN profile:
FieldValue
Servervpn.example.com
VPN TypeIKEv2 EAP (Username/Password)
Username(username from pfSense)
Password(user password)
CA certificateSelect automatically
  1. Tap Save and connect.

Split Tunnel vs Full Tunnel

The tunneling mode determines which client traffic passes through the VPN.

Full Tunnel

With full tunneling, all client traffic is routed through the VPN, including internet access. This mode provides maximum protection but increases VPN server and bandwidth load.

To configure Full Tunnel:

  1. Under VPN > IPsec > Mobile Clients, uncheck Provide a list of accessible networks to clients.
  2. In Phase 2, set Local Network to Network / 0.0.0.0/0.
  3. Configure an outbound NAT rule for VPN client traffic: Firewall > NAT > Outbound - add a rule for the 10.10.10.0/24 subnet on the WAN interface.

Warning:

With Full Tunnel, Outbound NAT must be configured for the VPN client subnet. Without it, VPN clients will not have internet access through the tunnel.

Split Tunnel

With split tunneling, only traffic destined for specified networks passes through the VPN. All other traffic (including internet) uses the client’s regular connection.

To configure Split Tunnel:

  1. Under VPN > IPsec > Mobile Clients, check Provide a list of accessible networks to clients.
  2. In Phase 2, create a separate entry for each protected subnet (for example, 10.1.0.0/24 for LAN, 10.2.0.0/24 for the server network).
  3. The subnet list from Phase 2 will be automatically pushed to clients.

DNS Considerations with Split Tunnel

With Split Tunnel, DNS queries may be routed through either the VPN or the local connection. This creates a DNS leak risk - queries for internal domains may be sent through the ISP.

To minimize DNS leakage:

  • Push a DNS server to clients through the Mobile Clients settings.
  • On Windows: use the NRPT (Name Resolution Policy Table) to route DNS queries for specific domains through the VPN.
  • On macOS/iOS: DNS traffic to the specified server is automatically routed through the VPN when routes are correctly configured.

Troubleshooting

Client Cannot Connect

ProblemCauseSolution
Timeout during connectionUDP 500/4500 blockedVerify firewall rules on WAN and with the ISP
IKE authentication credentials are unacceptableIncorrect username/passwordVerify credentials in User Manager
The certificate chain is not trustedCA certificate not installedInstall the CA certificate in the trusted store on the client
The remote server is not respondingIncorrect server addressVerify the server address in client settings and DNS resolution

Certificate Errors

ProblemCauseSolution
Certificate has expiredCertificate validity period elapsedReissue the certificate in Cert. Manager
Certificate name mismatchCN/SAN does not match the addressRecreate the server certificate with the correct SAN
iOS rejects certificateLifetime > 825 daysRecreate the server certificate with Lifetime of 825 or less
Windows: Error 13801Server certificate issueEnsure the CA is installed in Local Machine, not Current User

EAP Errors

ProblemCauseSolution
EAP_MSCHAPV2 failedIncorrect credentialsReset the user password in User Manager
no EAP method selectedWrong Authentication MethodSet EAP-MSCHAPv2 in Phase 1
Connection drops after 1 secondUser not in the required groupVerify group restrictions in Mobile Clients

Connected but No Access to Resources

ProblemCauseSolution
Cannot ping LAN hostsMissing rules on the IPsec tabCreate rules allowing traffic from the VPN pool
DNS not workingDNS server not pushed to clientConfigure DNS Server in Mobile Clients
No internet with Full TunnelMissing Outbound NATAdd an Outbound NAT rule for the VPN subnet

Diagnostic Commands

# View active IKEv2 sessions
ipsec statusall

# View connected mobile clients
ipsec leases

# View IPsec logs in real time
clog -f /var/log/ipsec.log

# Restart IPsec service
ipsec restart

Related Sections

Last updated on