Summary
OPNsense 24.1 has now been released. I have tested the script and it's compatible with the 24.1 release.
Important
I have rewritten the script since the 23.7.8-1
release. So there are breaking changes you will need to carry out before running the new script. Please see upgrade instructions below.
Upgrade Instructions
{instancename}
replace with the name for your instance in the config file, example london
would be come pia-london
for the WireGuard instance name. See Example config below. Then proceed to the below instructions.
- Delete the current cron entry.
- Backup your current config
cp /conf/PIAWireguard.json /conf/PIAWireguard.json.bk
via SSH - Populate the new
PIAWireguard.json
based on your old config file - Upload new
PIAWireguard.py
andPIAWireguard.json
file to/conf/
Can also do this via the below SSH commands, up to yourself how you wish to edit the new/conf/PIAWireguard.json
file.fetch -o /conf https://raw.githubusercontent.com/FingerlessGlov3s/OPNsensePIAWireguard/24.1-1/PIAWireguard.py fetch -o /conf https://raw.githubusercontent.com/FingerlessGlov3s/OPNsensePIAWireguard/24.1-1/PIAWireguard.json
- Upload new
actions_piawireguard.conf
file to/usr/local/opnsense/service/conf/actions.d/
Can also do this via the below SSH commandsfetch -o /usr/local/opnsense/service/conf/actions.d https://raw.githubusercontent.com/FingerlessGlov3s/OPNsensePIAWireguard/24.1-1/actions_piawireguard.conf
- Run
service configd restart
to refresh new actions file via SSH - There's a few bits in the WireGuard section in OPNsense you need to rename
- Rename current WG instance name to
pia-{instancename}
fromPIA
- Rename current WG peer to
pia-{instancename}-server
fromPIA-Server
- Rename current WG instance name to
- If your using port forwarding rename the alias to
pia_{instancename}_port
fromPIA_Port
- Ensure you applied all changes
- Run the new script via SSH in debug mode and ensure it's working
python3 PIAWireguard.py --debug
, should returninstancename tunnel up - last handshake x seconds ago
as the last log entry - Then run again but this time forcing a it to change server
python3 PIAWireguard.py --debug --changeserver instancename
, to ensure all changes will apply and work. - If all is working correctly, then re-create the cron entry, see main README for example as command name changed to
PIA WireGuard Monitor Tunnels
- Now double check all your configured routes and rules, ensure IP leaking isn't happening etc
Example Config
Example config
{
"opnsenseURL": "https://127.0.0.1:443",
"opnsenseKey": "/FQDXExojUWWuBdnPEPCUt98vnrQOdLxFqypTIEhE41304uYgA68ZJw7fveXBpXkMHqiAdx04cRAlLwh",
"opnsenseSecret": "p+Gi4uE1xypuGIptbhrDylGKcNd9vaRpQ298eH0k6SFRQ6Crw4fLk0cIA0eSuKvWEN0hKx8JaIGUtNPq",
"piaUsername": "p1234567",
"piaPassword": "EncryptAllTheThings",
"tunnelGateway": null,
"opnsenseWGPrefixName": "pia",
"instances": {
"london": {
"regionId": "uk",
"dipToken": "",
"dip": false,
"portForward": true,
"opnsenseWGPort": "51815"
}
}
}