GUIDE: Setting up Transmission with OpenVPN and PIA

Supa

Patron
Joined
Jan 10, 2014
Messages
204
0) Full script on gist. I made this for myself to automate a boring and long process. If you don't know what you're doing you should probably do it the 'hard' way first so you understand at least what the script is doing. It's also just for Private Internet Access (PIA) because I have PIA.

1) Tested on my: 9.3-RELEASE-p5 FreeBSD 9.3-RELEASE-p5 #1 f8ed4e8: Fri Dec 19 20:25:35 PST 2014

2) Not responsible for this losing your data, formatting your drives or your wife leaving you. This is supposed to be run inside the jail. It requires at least curl or wget to be installed. Tested with Transmission plugin jail &

3) Code should work like this:

Code:
jls
jexec [JAILID] tcsh
cd /tmp
wget --quiet --no-check-certificate -O pia.sh https://gist.githubusercontent.com/jedediahfrey/6d475dcc34c710f62a7c/raw/d9e2c8f26da0da5ba4e347df1c0210fde42884a8/pia.sh
chmod +x pia.sh
./pia.sh


rgATVw2.png

7Oje25t.png


The end of the script should show you this:

Code:
Starting openvpn.
Waiting 10 seconds for OpenVPN to spin up
If these are different, OpenVPN is working
Old IP: 68.[x].[x].[x]
New IP: 179.[x].[x].[x]


Anyone patient enough to step me through this? I'd really appreciate it. Been thinking of subscribing to PIA. I'm just still a freenas newbie.
 

Mike1980

Cadet
Joined
Apr 10, 2015
Messages
3
Hi, I'm hoping someone might have an idea.... I have modifed the process to suit my vpn provider and I'm getting the following error

Sun Apr 12 03:40:15 2015 Could not retrieve default gateway from route socket:: No such process (errno=3)
Sun Apr 12 03:40:15 2015 Cannot allocate TUN/TAP dev dynamically
Sun Apr 12 03:40:15 2015 Exiting due to fatal error

To me that says that it cannot create of find a tun interface to use. Has anyone had issues in getting the tunnel interface to work? Do I need to create a tunnel interface outside of the jail?

thanks in adavnce
 

Supa

Patron
Joined
Jan 10, 2014
Messages
204
So is there anyway to view the torrent IP in transmission after it starts downloading something?

Also this is the error I'm getting.

vHa7irF.png
 
Last edited:

denist

Contributor
Joined
Jan 28, 2013
Messages
188
Hi created a jail with the transmission plugin..

and ran the script the openvpn worked fine...

after i install the rest of the plugins sickrage sabnzbd couchpotaot and did some nzbtomedia stuff with package upgrade and nginx....

now when i wan to start the opvpn which it does automatically it says this..

Apr 27 20:12:36 transmission_1 openvpn[52491]: OpenVPN 2.3.6 amd64-portbld-freebsd9.3 [SSL (OpenSSL)] [LZO] [MH] [IPv6] built on Apr 10 2015
Apr 27 20:12:36 transmission_1 openvpn[52491]: library versions: OpenSSL 0.9.8za-freebsd 5 Jun 2014, LZO 2.09
Apr 27 20:12:36 transmission_1 openvpn[52491]: Sorry, 'Auth' password cannot be read from a file
Apr 27 20:12:36 transmission_1 openvpn[52491]: Exiting due to fatal error
Apr 27 20:12:36 transmission_1 root: /usr/local/etc/rc.d/openvpn: WARNING: failed to start openvpn

what happened is this easilly fixed..

thanx
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
i got it fixed without deleting jail

when i did the update with pkg.... it updated the openvpn to

pkg: openvpn reinstalled: 2.3.6_3 -> 2.3.6_3 i got this from the logs folder from jail

which broke my vpn. failed to start error

the way i fixed it was to do a pkg delete openvpn-2.3.6_3

and deleted the openvpn folder with the pass txt and certs.

then reran the script. and it works now.

does anyone know why it breaks the vpn. when you do an update pkg.

thanx
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
hope this helps people do a reinstall..

i have done one jail with transmission, sabnzbd, sickrage, and couchpotato installed and then openvpn in that same jail.

also if you make a mistake with the username and pass you cannot fix it. even with a reinstall over ther top it will still error. you need to delete package and folder openvpn then rerun the script.
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
I don't use pkg with Vpn when i did the install all worked fine but once I did the rest of my plugin installation and script for nzbtomedia openvpn stop working and didn't know how to fix. So I used pkg remove openvpn and also deleted the openvpn folder. Then reran the script if your and it started again to work as it should. Do you know how to bind transmission to Vpn. Do u have a script I have found some answers but don't know where to put the .sh file to boot at start up.

Thanx


Sent from my iPhone using Tapatalk
 
Joined
Mar 6, 2014
Messages
686
If you use pkg upgrade, the vpn from the ports could be replaced by the pkg one, and that one is not compiled with PW_SAVE=ON.
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
Yes that's what I think what happened when u was installing other jpg it did and upgrade where it broke the Vpn. That is why u did the pkg remove and deleted the openvpn folder and did the reinstall of it and it worker again. The only thing I'm trying to do now idle to bind transmission to it on boot or restart that is where I'm stuck. And the guides I have found don't tell me where to put the script for start up.


Sent from my iPhone using Tapatalk
 
Joined
Mar 6, 2014
Messages
686
You probably should be a bit more clear in your question and give a little more info on what you want to achieve exactly (and what script you found that you think could help you).
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
ok i setup openvpn with the script provided here. all works well this was done in the transmission plugin jail...

now i tried this guide to bind transmission to openvpn but cant figure out why it does not work...

https://forums.freenas.org/index.ph...en-using-pia-i-e-creating-a-killswitch.27640/

i made the .sh script but keep getting some error. so maybe the formatting is wrong...

and would like it to boot up at start up as openvpn first then the rest of the plugins.

when i added the .sh path into transmission rc.d bfore the curly i get cant find file.

so i got stuck

unless someone know of a better way.

My goal is to have openvpn start and to bind transmission to it like a kill switch when openvpn fails or pia in my case drops that transmission stop downloading..

i have set up my freenas to turn on everday at 5pm and shut down on a script when there is no lan activity on certin ip address from midnight.

so i need to have these service to start up and bind..

hope this is understandable.

thanx Denis
 
Joined
Mar 6, 2014
Messages
686
I have script for that to use with cron, check this. When i find time, i will be working on a script that uses the OpenVPN hooks instead of cron jobs, but until then this works great.
Btw. why do you shut down FreeNAS every night between midnight and 5pm? You wear your system less when you keep it always on. Also you could (and sould) schedule long and short smart tests and scrubs in that time. I use the schedule proposed by @cyberjock here.
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
ok i have extended my peroid of shutdown to 4 am added the scrubs and smart test just changed the times....

now i have been using this script for the time being

https://github.com/amussey/FreeNAS-Transmission-OpenVPN and at the moment it is loading at start up and have been told by the author that transmission stops when vpn fails..

his script i add my log in user name and password to pia not the proxy one and it woks... does this add the encryption or not....

not sure if it does this but maybe someone can look at it and see if it does.... not sure about encryption yet...

now if you dont mind im a little bit of a noob but my head is getting the hang of stuff and understanding....

you use the script here to install vpn with prox username and password.

then u load you cron job. to bin transmission in a sense.

what do u do to load the scripts...

sorry i get stuck where to add files for startup...

Denis

i turn of becuase of the wife asks why is it on lol so i turn it on and then it turns off when there is no lan activity..

thanx
 
Joined
Mar 6, 2014
Messages
686
I don't know that script, but i do know that if my OpenVPN connection is down, Transmission keeps running. It just can't connect to the ouside world, which is exactly what we want :) Have you actually checked if Transmission shuts down when you terminate OpenVPN? Sounds crazy to me.
I use 2 scripts. 1 is loaded by ipfw on startup (you can use a script as your firewall rules file, how cool is that!) and the other one is started using a cron job. Can't check how i set up the cron job right now. You might want to read the whole tread btw (the one with the scrips), it might help you to understand some thins a little more.
 

denist

Contributor
Joined
Jan 28, 2013
Messages
188
could you tell me what openvpn script you used is it this one

and if you dont mind where to put the other scripts...
 
Joined
Mar 6, 2014
Messages
686
I used this guide. Be sure to not only read the first post, further on is more info on how to get it to work with password login, but it seems like you already got that to work.

Then just replace the ipfw rules file with the ipfw script in my post and run a cron job to execute the 2nd script. Every jail has it's own cron (you need to edit /etc/crontab inside the jail), but it is possible to also use the FreeNAS cron. It is something like
Code:
jexec # /path/to/script.sh
(without the "1." of course) with # being the jail number. But since jail numbers may change on reboot and it certainly changes if you restart the jail, jou can also use the jail name:
Code:
jexec jailname /path/to/script.sh

The path to the script is the path from inside the jail. You can put the scrips anywhere you want, mine are in a shared folder, mounted in the jail (for example the 'media' folder). That way I can easily edit it from my laptop. Make sure they are executable. If you use a script for the firewall rules, in /etc/rc.conf the line must be:
Code:
firewall_enable="YES"
firewall_script="/etc/ipfw.rules" 
 
Top