authcha learn

Learn / Integrations

OpenVPN users through RADIUS on pfSense

Module 3 of 6 · 30 minutes

By the end you can

  • Connect a pfSense OpenVPN server to Authcha as its authentication backend
  • Give one user a fixed tunnel address and routes
  • Explain why a route behind a client needs a kernel route, and how the agent adds it safely
  • Name the limits: no accounting, no interactive second factor

One account for everything

Remote-access VPN users sign in to pfSense's OpenVPN server with the same usernames and passwords as everyone else. pfSense asks Authcha over RADIUS, so there is no user list on the firewall.

Set it up

  1. Register the firewall in Authcha. RADIUS Clients → Add (the address its RADIUS packets come from, and a secret), then Devices → Add with the same address, device type Captive portal / hotspot (PAP) (the plain username-and-password profile; it has nothing to do with the captive portal feature itself) and CoA mode: none. If the firewall puts another address in NAS-IP-Address, add it under Additional addresses, or the request is refused as an unknown device.
  2. Add Authcha on pfSense: System → User Manager → Authentication Servers → Add. Type RADIUS, protocol PAP (Authcha verifies a stored hash, so CHAP and MS-CHAP cannot work), Authcha's address, the secret, Authentication only, port 1812, and the RADIUS NAS IP attribute for the interface you registered.
  3. Use it in the OpenVPN server: VPN → OpenVPN → Servers, mode Remote Access (User Auth) or (SSL/TLS + User Auth), backend = the server from step 2. With SSL/TLS + User Auth each user needs a client certificate and a password, the recommended setting and the only second factor today. Turn Enforce local group off unless you create a group of the same name on the firewall.

Everything the central store decides applies: a disabled user, a locked user (three wrong passwords lock for 15 minutes; Users → Unlock clears it) or a disabled user type is refused, with the reason in Live Auth.

A fixed address and routes for one user

Under Network Access → Network Policies → Fixed address and routes for one user, enter the user, an address such as 10.99.0.50, optionally a netmask, and routes. They apply from the next login. Two different fields exist and the difference matters:

In AuthchaIn the pfSense overrideWhat happens
Routes to push to the VPN client (10.1.0.0/24)IPv4 Local Network/sThe client gets push "route 10.1.0.0 255.255.255.0" at its next connection
Framed-Route (192.168.5.0/24 gw metric)IPv4 Remote Network/sOpenVPN learns the network is behind this client. No kernel route is added by the override

pfSense gave the client the fixed address in the lab but did not act on Framed-Route: that RFC 2865 attribute names a network behind the user, and pfSense's OpenVPN only reads routes from a client-specific override (CSO) matched on the user name. So the pfSense agent, run with --openvpn, keeps one override per user that has routes. Turn Username as Common Name on, because the override is matched on the user name.

A network behind a client needs a kernel route

The override only tells OpenVPN which client owns the network. For traffic to reach it, pfSense also needs a route through the OpenVPN server's interface. Two ways:

  • Let the agent do it: add --openvpn-routes. For each network behind a client it runs route add -net NET -interface ovpnsN, without restarting OpenVPN so no connected user is dropped. It never replaces a route that already exists, refuses a network broader than /8, removes a route again when the user or route goes, and adds it back within ten minutes after OpenVPN or the firewall restarts.
  • By hand: add the network to IPv4 Remote Network/s on the OpenVPN server. Saving restarts OpenVPN and drops every connected user, which is why the agent does not do it.

Check with netstat -rn -f inet | grep 192.168.5 on the firewall: the network must show the ovpns interface.

Web limits for VPN users

pfSense's OpenVPN sends no accounting, so Authcha has no session to find a VPN user by. A user with a fixed address is therefore treated as signed in at that address, and the Squid agent applies their web policy there, provided the address is the one their traffic comes from after the tunnel and Squid sees that traffic (add the OpenVPN interface to the interfaces Squid serves). A VPN user without a fixed address gets no web limit.

Limits to remember

  • No accounting: VPN sessions are not in Network Sessions and have no session quotas. Use pfSense's Status → OpenVPN.
  • No interactive one-time code: a second factor today is the client certificate. SMS and WhatsApp codes are for the captive portal and the console, not the VPN.

Test the RADIUS side first

docker run --rm freeradius/freeradius-server:3.2.10 radtest -x alice 'her password' AUTHCHA_HOST 0 'the shared secret' 0 FIREWALL_ADDRESS

Received Access-Accept means the device, user and password are right. Access-Reject plus the reason in Live Auth names the cause. Then connect with the OpenVPN client while watching Live Auth.

LabHands-on

On the demo as demo-viewer (password Authcha-View-2026) for steps 1 and 2.

  1. Open Network Policies on the demo and find Fixed address and routes for one user. Which demo users have one?
  2. Open Users and find a user with a fixed address and one with a route behind the client.
  3. On a lab pfSense, follow steps 1 to 3 and connect a test user with a certificate and password.
  4. Give the user a fixed address and a pushed route. Reconnect and read the tunnel address and routes on the client.
  5. Add a Framed-Route for a network that exists only in your lab. Run the agent with --openvpn --openvpn-routes --dry-run, then for real, and check netstat -rn.
  6. Try a Framed-Route for a network already reachable another way and read what the agent says.

Check yourselfQuiz

1Why does the VPN auth server use PAP?
2What does the override alone do for a Framed-Route network?
3Why does the agent add the kernel route instead of restarting OpenVPN?
4Which network is dangerous to give as a Framed-Route?
5Does a VPN session appear in Network Sessions?

Cheat sheetKeep this

  • pfSense: System → User Manager → Authentication Servers → RADIUS, PAP, then the OpenVPN server backend.
  • Device type Captive portal / hotspot (PAP), CoA none.
  • Fixed address and routes: Network Policies → Fixed address and routes for one user. Push routes vs Framed-Route.
  • Agent: --openvpn (overrides) and --openvpn-routes (kernel route, no restart, never over an existing route, nothing wider than /8).
  • No accounting, no interactive second factor. Certificate + password is the second factor.
  • Not verified on a real OpenVPN server: pilot first.
  • Read more: pfSense OpenVPN.