This guide explains how to configure a router running pfSense with Private Internet Access (PIA) OpenVPN configuration files.
Note: These steps are written for pfSense CE 2.8.1. Some labels may differ slightly on older pfSense versions.
Jump To:
- Step 1: Download the OpenVPN Configuration Files
- Step 2: Import the PIA Certificate Authority
- Step 3: Configure the OpenVPN Client
- Step 4: Assign the OpenVPN Interface
- Step 5: Configure Outbound NAT
- Step 6: Route LAN Traffic Through the VPN
- Step 7: Confirm the VPN Connection
Step 1: Download the OpenVPN Configuration Files
- Go to Downloads.
- Scroll down to the OpenVPN configuration files and download the one that best fits your needs. (You can find more about PIA’s OpenVPN configuration files here).
- Once downloaded, extract the downloaded archive.
Step 2: Import the PIA Certificate Authority
The certificate authority file authenticates your connection to PIA's servers. To import it:
- Log into the pfSense web interface.
- Go to System > Certificates > CAs.
- Click Add.
- In Descriptive name, enter a name for the certificate authority, such as PIA.2048 or PIA.4096.
- Set Method to Import an Existing Certificate Authority.
- Open the PIA certificate authority file that matches your chosen configuration. You will find it in the openvpn folder extracted from the archive you downloaded earlier. In this example, the file is named ca.rsa.2048.crt.
- Open the certificate file in a text editor and copy the full contents, including the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines.
- Paste the certificate into Certificate Data.
- Click Save.
Step 3: Configure the OpenVPN Client
For this step, use the data from one of the .ovpn configuration files in the OpenVPN folder where you found the certificate file. This guide uses the us_california.ovpn configuration.
- Open an ovpn configuration file.
- Note the details you will need for the steps below.
Then, in your pfSense router interface:
- Go to VPN > OpenVPN > Clients.
- Click Add.
- Configure the following settings:
- Server Mode: Peer to Peer (SSL/TLS)
- Device mode: tun – Layer 3 Tunnel Mode
- Interface: WAN
- Protocol: match the proto line in your .ovpn file (UDP on IPv4 only or TCP on IPv4 only)
- Local port: leave blank
- Server host or address: Enter the hostname from the remote line in your .ovpn file (for example, us-california.privacy.network)
- Server port: Enter the port from the same remote line (for example, 1198)
- Proxy host or address: Leave blank
- Proxy port: Leave blank
- Proxy Authentication: None
- Description: Enter a name for this connection, such as “PIA California.”
- Under User Authentication Settings:
- Username: Enter your PIA username (format: p1234567)
- Password: Enter your PIA password
- Under Cryptographic Settings:
- Use a TLS key: Uncheck this.
- Peer Certificate Authority: Select the certificate you imported in Step 2.
- Data Encryption Algorithms: Select the available AES-GCM options, such as AES-256-GCM and AES-128-GCM.
- Fallback Data Encryption Algorithm: Select AES-128-CBC.
- Auth Digest Algorithm: Match the auth line in your .ovpn file (for example, SHA1).
- Compression: Disable compression.
- In the Clients tab, check the following two options:
- Don’t Pull Routes
- Pull DNS
- In Custom options, paste the following:
persist-key
persist-tun
remote-cert-tls server
reneg-sec 0
auth-retry interact
- Set Gateway Creation to IPv4 only.
- Click Save.
Step 4: Assign the OpenVPN Interface
- Go to System > Routing and set the default gateway to your WAN gateway.
- Go to Interfaces > Assignments.
- In Available network ports, select the OpenVPN client interface for your PIA connection.
- Click Add.
- Click on the newly created OPT interface to open it.
- Check Enable.
- In Description, enter “PIA_VPN.”
- Click Save > Apply Changes.
- Go back to VPN > OpenVPN > Clients, open the PIA client entry, and click Save without making any changes. This refreshes the OpenVPN configuration after assigning the interface.
Step 5: Configure Outbound NAT
- Go to Firewall > NAT > Outbound.
- Select Manual Outbound NAT rule generation and click Save.
- Click Add to create a new rule and configure the following:
- Interface: Select the PIA_VPN interface you created in Step 4.
- Address Family: IPv4
- Protocol: Any
- Source: LAN net
- Destination: Any
- Translation / target: Interface address
- Description: NAT LAN through PIA VPN
- Click Save > Apply Changes.
- Make sure this rule appears above any broader matching NAT rules.
Step 6: Route LAN Traffic Through the VPN
First, configure pfSense to skip policy-routing rules when their selected gateway goes down:
- Go to System > Advanced > Miscellaneous.
- Enable Do not create rules when gateway is down.
- Click Save.
Next, create the VPN routing rule:
- Go to Firewall > Rules > LAN.
- Click Add to create a new rule above the default LAN rule.
- Configure the following settings:
- Action: Pass
- Interface: LAN
- Address Family: IPv4
- Protocol: Any
- Source: LAN net
- Destination: Any
- Click Display Advanced and set Gateway to the PIA OpenVPN gateway.
- In Description, enter “Route LAN through PIA VPN.”
- Click Save > Apply Changes.
Then, add a fallback block rule directly below the VPN routing rule and above the default LAN rule:
- Action: Block
- Interface: LAN
- Address Family: IPv4
- Protocol: Any
- Source: LAN net
- Destination: Any
- Description: Block LAN traffic if PIA VPN is unavailable
Click Save > Apply Changes. This rule order prevents LAN traffic from falling back to the WAN connection if the PIA gateway goes down.
Note: This guide routes IPv4 traffic through the VPN. If IPv6 is enabled on your network, IPv6 traffic may use your regular connection unless you disable IPv6 or configure IPv6 routing separately.
Step 7: Confirm the VPN Connection
- Go to Status > OpenVPN and confirm that the PIA client shows as connected.
- From a device connected to your LAN, visit an IP-checking page such as PIA’s What’s My IP Address and confirm that the public IP address matches your selected PIA server location.