Hello everyone,
I was wondering if anyone had success setting up a jail running transmission and connectin to PIA VPN using WG instead of OpenVPN.
I'd like to switch to this solution but i don not have the knowledge to do it on my own: i can follow a guide for openvpn and understand what is going on but i wouldn't be able to start one from scratch.
If anyone would be so kind to help, i'd be very glad,
Cheers
I managed to use wireguard for my PIA VPN connection. Also, I managed to have wireguard connect automatically at startup, opening a port and forwarding it to transmission.
I started from the scripts found here:
Scripts for manual connections to Private Internet Access - glorious1/manual-connections
github.com
I put all these scripts in /PIA in my jail. I changed most of the references from relative to absolute paths. In run_setup.sh I specified the location of a file with my VPN credentials, and I set the connection mode to wireguard:
Code:
PIA_AUTOCONNECT="wireguard"
I also fixed a small error in connect_to_wireguard_with_token.sh that prevented port forwarding: the variables PF_GATEWAY and PF_HOSTNAME must exported in order to be used by the port_forwarding.sh script.
Code:
PIA_TOKEN=$PIA_TOKEN \
PF_GATEWAY="$(echo "$wireguard_json" | jq -r '.server_vip')" \
export PF_GATEWAY
PF_HOSTNAME="$WG_HOSTNAME" \
export PF_HOSTNAME
Then I wrote another simple script and saved it in /PIA as VPNstart.sh:
Code:
#!/usr/local/bin/bash
cd /PIA
/usr/local/bin/bash /PIA/run_setup.sh
it is important to change the working directory to where your scripts are, otherwise the wireguard script won't find the authentication certificate (ca.rsa.4096.crt). And I added these lines in /etc/crontab:
Code:
@reboot root /PIA/VPNstart.sh
*/15 * * * * root /PIA/refresh_pia_port.sh
This way the VPNstart.sh scripts starts at every reboot, calling run_setup.sh and the rest of the VPN connection procedure.
The refresh_pia_port.sh script is run every 15 minutes to keep the port open.
However, it is important to change the SHELL line in crontab to use bash instead of sh:
Code:
SHELL=/usr/local/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
Hope this helps. My transmission jail has been running smoothly for more than a day now.