This guide explains how to configure OpenVPN on a router running OpenWRT using a Private Internet Access (PIA) configuration file and the LuCI web interface.
Jump To…
Step 1: Install the Required Packages
Step 2: Upload the PIA Configuration File
Step 3: Add Your PIA Credentials
Step 4: Start the VPN Connection
Step 5: Configure the Firewall
Requirements
To complete this setup, you need:
- A router running OpenWRT with access to the LuCI web interface.
- A PIA OpenVPN configuration file. You can download one from the OVPN files article or generate a custom one using the PIA OpenVPN Configuration Generator.
- Your PIA username and password.
- The PIA DNS server you want to use (optional).
Step 1: Install the Required Packages
Before you can configure OpenVPN, you need to install two packages via LuCI.
- In LuCI, go to System > Software.
- Click Update lists to fetch the list of available packages.
- In the Filter field, search for “luci-app-openvpn” and click Install in the Available packages tab.
- Search for “openvpn-openssl “and click Install in the Available packages tab.
Once installed, a VPN menu will appear in LuCI.
Step 2: Upload the PIA Configuration File
- In LuCI, go to VPN > OpenVPN.
- Under OVPN configuration file upload, enter a name for the connection (for example, PIA_California) and upload your PIA .ovpn file.
- Click Browse and select the .ovpn file for the server location you want to use.
- Click Upload. The configuration will appear in the OpenVPN instances table above.
Step 3: Add Your PIA Credentials
- Click Edit next to the configuration you uploaded.
- In the section labelled Section to add an optional 'auth-user-pass' file with your credentials, enter your PIA username on the first line and your PIA password on the second line.
- Find the line beginning with auth-user-pass in the configuration text box and add the full path to the .auth file on the same line. The full path is shown just above the credentials text box and usually follows this format:
auth-user-pass /etc/openvpn/<config-name>.auth
- Click Save.
Step 4: Start the VPN Connection
- Go to VPN > OpenVPN.
- Click Start next to your PIA configuration in the OpenVPN instances table. Wait up to 10 seconds for the connection to start.
Note: If clicking Start does not work, tick the Enable checkbox first and click Save & Apply, then try again.
Step 5: Configure the Firewall
At this point the router can use the VPN, but devices connected to your router won't be able to access the internet yet. You need to assign the VPN interface to the WAN firewall zone.
- Go to Network > Interfaces.
- Click Add new Interface.
- Fill in the following details:
- Name: OpenVPN
- Protocol: Unmanaged
- Interface: tun0
- Click Create Interface.
- In the General Settings tab, uncheck Bring up on boot.
- In the Firewall Settings tab, assign the firewall zone to wan.
- Click Save & Apply.
- Reboot the router.
Step 6: Test the Connection
Once connected, verify that your traffic is going through PIA by visiting ipleak.net or dnsleaktest.com from a device connected to your router. Your IP address should show a PIA server location, not your real IP address.
DNS not working? Go to Network > Interfaces > LAN, disable peer DNS, and enter a PIA DNS server address in the Use Custom DNS field.