pfSense: IPsec VPN with Okivo
Documentation
On this page
Plan feature RADIUS/VPN, from the Team plan on.
With the package pfSense-pkg-okivo users approve every IPsec VPN sign-in on a pfSense by push in the Okivo app. You don't need a separate RADIUS server for this.
The package brings the small service okivod. It runs on the firewall, answers RADIUS only on 127.0.0.1
and appears in pfSense as the authentication server “Okivo”. Per sign-in it does two steps:
- It checks the password.
- It triggers the push through the Okivo plugin in your Keycloak.
Client ──IKE_AUTH (EAP or Xauth)──> pfSense/strongSwan ──RADIUS (127.0.0.1)──> okivod
│ 1. check password
│ 2. request push
▼
Keycloak + Okivo plugin ──> Okivo app
The settings form under VPN → Okivo is in English like the pfSense GUI. The status page and the messages follow the pfSense language (System → General Setup → Language): German or English.
Requirements
- pfSense on amd64 or on a Netgate device with ARM (arm64).
- Keycloak with the Okivo plugin, realm set up (Install the Keycloak plugin); the plan includes RADIUS/VPN.
- The pfSense reaches Keycloak via HTTPS.
- The realm's inbound API key. Without a separate key that's the Tenant API Key from the portal; how to set a separate one is described in Inbound API key.
- The users have set up a device in the Okivo app.
Which password source for which clients
Passwords come from one of four sources. That determines which clients work without extra software:
| Source (VPN → Okivo) | IKEv2, built-in clients (Windows, macOS, iOS) | IKEv2, strongSwan app or Windows profile with EAP-TTLS | IKEv1 with Xauth |
|---|---|---|---|
| pfSense EAP users (VPN → IPsec → Pre-Shared Keys, type EAP) | yes (EAP-MSCHAPv2) | yes | yes |
| pfSense users (User Manager, privilege “IPsec xauth Dialin”) | no | yes | yes |
| Active Directory / LDAP | no | yes | yes |
| Keycloak | no | yes | yes |
Why the built-in clients only work with EAP users: they can only do EAP-MSCHAPv2 (or certificates). For MSCHAPv2 the verifier needs the password in plain text or as an NT hash, and only the pfSense EAP users have that. Keycloak, LDAP and the User Manager store passwords in a way that doesn't allow MSCHAPv2 checks.
Active Directory with built-in clients: then the way is a separate RADIUS server with Okivo, see RADIUS with FreeRADIUS.
Setup
Install the package. In the pfSense shell (Diagnostics → Command Prompt or SSH), first check which package fits, then install it:
Shellpkg config abi # e.g. FreeBSD:16:amd64 → package …-fbsd16-amd64.pkg pkg add -f https://okivo.app/releases/pfsense/<version>/pfSense-pkg-okivo-<version>-fbsd16-amd64.pkg
There is one package per FreeBSD version:
fbsd15for pfSense 2.8,fbsd16for pfSense 2.9.pkgrejects the wrong one with "wrong architecture". Netgate devices with ARM need…-arm64.pkg. The packages are public underhttps://okivo.app/releases/pfsense/<version>/, without sign-in. In the file name the version has a dot instead of-(pre-release1.0.0-rc.1→pfSense-pkg-okivo-1.0.0.rc.1-fbsd16-amd64.pkgin the folder1.0.0-rc.1/). The package is not yet in Netgate's package catalogue.VPN → Okivo:
- Tick Enable.
- Enter the Keycloak URL (e.g.
https://id.example.com), Realm and API key (the realm's inbound API key). - Name in the push: appears in the app as “VPN · name”. Empty = hostname of the firewall.
- Choose the Password source and fill in its fields (LDAP: LDAP server, Bind DN, Base DN, User filter; Keycloak: see below).
- For EAP-TTLS choose the Certificate for EAP-TTLS, ideally the same server certificate as for IKE.
- Timeout (seconds): how long
okivodwaits for the approval, at most 65. Okivo itself waits 60 seconds. - Save. The package then creates the authentication server “Okivo” and starts
okivod.
VPN → Okivo → Status & Test → “Test”:
- Without a user the test checks Keycloak, API key and plan.
- With a user it also checks the password and sends a push to that user's phone.
VPN → IPsec → Mobile Clients:
- User Authentication: “Okivo”.
- RADIUS retransmit: timeout 10, attempts 7, base 1. With this pfSense waits a good 70 seconds for the approval. With the defaults (2 s, 4 attempts, base 1.4) pfSense gives up after about 15 seconds; that's too short for an approval on the phone.
Phase 1:
- IKEv2: authentication method EAP-RADIUS, “My Certificate” = server certificate.
- IKEv1: Mutual PSK + Xauth.
- Not EAP-MSCHAPv2. With it, strongSwan checks the password itself against the EAP users and never asks
okivod: the sign-in works, but without a push. Also under Mobile Clients choose only Okivo for “User Authentication”, not “Local Database” as well.
Users:
- With the source “pfSense EAP users”, create one entry of type EAP per user under VPN → IPsec → Pre-Shared Keys.
- The username must match the user in Keycloak. For differing names, VPN → Okivo offers:
- Strip domain: “CORP\anna” and “anna@corp.example” become “anna” in Okivo.
- Append suffix: appended to the name, e.g.
@corp.example. - Lowercase: convert usernames to lowercase for Okivo.
Source Keycloak
okivod checks the password with the password grant of a dedicated client and then triggers the push
itself. The client must therefore not have a push step of its own:
- Create the client
okivo-vpn, enable only Direct Access Grants. - Create an authentication flow “VPN – password only”: a copy of “direct grant” with Username Validation and Password, without OTP and without Push MFA.
- In the client under Advanced → Authentication flow overrides, choose this flow for Direct Grant Flow.
- In VPN → Okivo: Password source “Keycloak”, Keycloak client
okivo-vpnand – if the client is confidential – the Client secret.
How a sign-in works
- Wrong password: no push is sent; the sign-in is rejected immediately.
- Correct password:
okivodwaits up to 60 seconds for approval or block in the app. The app shows “VPN · <name of the firewall>” with the client's public IP. - Repeated requests: pfSense repeats the RADIUS request while the response is pending.
okivodanswers repetitions from the running process; exactly one push is sent. - EAP-TTLS: Windows sends the password inside the tunnel as PAP. The strongSwan app sends an inner EAP;
okivodthen asks for the password via EAP-GTC. - VPN sign-ins have no number matching and no code: the user just approves.
pfSense updates
After a pfSense update, check whether the package is still installed; otherwise install it again with
pkg add. The settings remain in the pfSense configuration.
Troubleshooting
| Display | Cause |
|---|---|
| Status shows “no response” | Not approved in the app in time, or the push didn't arrive. |
| Sign-in aborts after about 15 s | “RADIUS retransmit” under Mobile Clients not set as above. |
| “plan without RADIUS/VPN” | Change the plan in the Okivo portal. |
| “user unknown in Keycloak” | The name doesn't match the Keycloak user, see the name mapping in step 6. |
| Sign-in works, but without a push; no entry under VPN → Okivo → Status | Phase 1 is set to EAP-MSCHAPv2 instead of EAP-RADIUS, or Mobile Clients also have “Local Database” selected. pfSense then never asks okivod. |
| Windows/iOS: sign-in fails immediately | The password source isn't “pfSense EAP users”: the built-in clients need EAP-MSCHAPv2. |
Other places to look:
- Status → System Logs → IPsec
- Status → System Logs → General (entries from
okivod) - VPN → Okivo → Status & Test