Nowadays, it is prudent to protect your privacy when downloading torrents on the net.  A few lawsuits have recently been brought against ISP’s by businesses seeking damages from users allegedly downloading illegal content. Many of these lawsuits have centered on trying to get the ISP’s to release lists of customer IP addresses along with their associated activity logs. In this post you will learn how to install a VPN in the Transmission jail and when correctly set up, all your Transmission traffic will subsequently go through the VPN.

Using the Sick Rage, Transmission and Couch Potato plugins, my NAS system is better than it has ever been and  I was also able to import my ZFS raid disks from my old N4F server with no problems. By following this post carefully you will easily be able to get OpenVPN installed and working though the FreeNAS Transmission jail to ensure only protected traffic is tunneled through our BT client. In my experience, this process is WAY easier that the setup required for N4F and I have setup 3 systems now with no problems using this method! Just so we’re clear, this post is NOT meant to be a tutorial on how to set up FreeNas. There are many ways to configure the FN server that depend largely on your system architecture – so head on over to the FN forums if you have basic operational questions. Here is a great article on configuring SickRage, SickBeard (seriously – who names this stuff??!!) and CouchPotato.

This how-to is adapted from a post in the FN forums by Tango and I have modified it to work with Torguard though it might work with other VPN providers as well (your mileage may vary). This tutorial assumes you have your Freenas server setup and working correctly and that you have installed and tested the Transmission plugin to your satisfaction. I am currently using Torguard for VPN and I can highly recommend them.  They offer many locations worldwide, are reasonably priced and have excellent customer service when you need it.  Here are the steps I followed to get VPN working on my FreeNas 11.1 server:

  1. You will need a VPN provider in order to get this going.  Click here to try Torguard.
  2. SSH into freenas. (I use PuTTy)
  3. Get a list of jails:
    root@freenas ~ : jls
    JID    IP Address      Hostname              Path
    3      -  192.168.1.50  transmission_1    /mnt/<volumename>/jails/transmission_1
  4. jexec into the jail (mine happens to be 3 – yours may vary)
    root@freenas: ~ : jexec 3 tsch /bin/sh #(if you are having trouble try- sudo jexec 3 /bin/sh)
    root@transmisssion_1: ~ / :
  5. Install bash. May be prompted several times – reply Y then press enter each time.
    root@transmission_1: ~ / : pkg install bash
  6. Install nano. Again, may be prompted several times. Reply Y each time.
    root@transmission_1: ~  / : pkg install nano
  7. Move to the /etc folder.
    root@transmission_1: ~ / : cd /etc
    root@transmission_1: ~ /etc :
  8. Fetch Portsnap via portsnap fetch:
    **This will take a while to download and ask for several prompts – you know the drill.
    root@transmission_1: ~ /etc : portsnap fetch
  9. Extract Ports to /usr/ports
    root@transmission_1: ~ /etc : portsnap extract

    **This will also take a long time and A LOT of scrolling will happen. It’s normal.

  10. Navigate to /usr/ports/security/openvpn
    root@transmission_1: ~ /etc : cd /usr/ports/security/openvpn
    root@transmission_1: ~ /usr/ports/security/openvpn :
  11. Make a clean install which allows us to set the option of a password file.
    root@transmission_1: ~ /usr/ports/security/openvpn : make install clean

    **Blue screen should appear. Press the DOWN arrow and the SPACE bar to ensure the [ ] next to PW_Save ( 5th option down) has an X in it. Should look this:
    x+[X] PW_Save   Interactive passwords may be read from a file
    (On latest versions of openvpn (Mar. 2016) you MAY NOT get an option #5 as described above, but openvpn appears to read passwords from a textfile anyways so you can safely skip this step.)
    **then press enter. Lots of things should happen now…

  12. Go to root directory of the transmission_1 jail:
    root@tranmission_1: ~ /usr/ports/security/openvpn : cd /
    root@transmission_1: ~ / :
  13. Enter Bash
    root@transmission_1: ~ / : bash
    root@transmission_1: ~ / :
  14. Make a directory for OpenVPN & our files that we will download from Torguard:
    root@transmission_1: ~ / : mkdir /usr/local/etc/openvpn
  15. Add lines to the rc.conf so OpenVPN starts when the jail starts:
    root@transmission_1 ~ / : cd /etc # Note – use Ctrl+o will write the file and Ctrl+X will exit.
    root@transmission_1 ~ /etc : nano rc.conf # File is open.
    # Add the following (can copy/paste using ctrl+C then right clicking in the shell)
    openvpn_enable=”YES”
    openvpn_configfile=”/usr/local/etc/openvpn/openvpn.conf”
    # Write via Ctrl+O. Press Enter
    # Exit via Ctrl+X.
  16. Move to a new folder (helps me keep things straight):
    root@transmission_1 ~ /etc : cd /media/
  17. Grab the Torguard files, you’ll likely need to grab them manually and install them through the FreeNas GUI as Torguard does not allow wget file transfers. If you have created your Transmission jail storage correctly (see link at beginning of article) you should be able to drag the Torguard files into your shared NAS ‘downloads’ directory and see them symlinked in your jail’s ‘/media’ directory.
    You will need a login CLICK HERE to check out Torguard. Here is the link once you are logged in: https://torguard.net/downloads.php. You will want to grab the ‘Standard Port 443/TCP Configs” in the “OpenVPN Config Files and Scripts” section (near the bottom).
  18. Unzip the Torguard openvpn files into the ‘Media’ folder:
    root@transmission_1 ~ /media : unzip TorguardPRO.zip
  19. Make a pass.txt file to hold your username and password.
    root@tranmission_1 ~ /media : nano pass.txt
    # Nano will pop up. ONLY type in the following (substituting your REAL username and password of course)
    USER
    PASSWRD
    # Press Ctrl+o. call it pass.txt. then enter. then Ctrl+X
  20. Configure the .ovpn file of your selected server. (I used a Canadian-based.ovpn’ as it is still legal to torrent in Canada at this time. Torguard asks that you NOT use US-based servers for torrenting)
    root@tranmission_1: ~ /media : nano 'Your_Selected.ovpn
    # On the auth-user-pass line add pass.txt after it like so: auth-user-pass pass.txt
    # Press Ctrl+o. call it Your_Selected.ovpn. then enter. then Ctrl+X
  21. Move the fixed Torguard files** into the correct folder we just created
    **The actual OpenVPN files we created in Step 20 above.
    #ca.crt next:
    root@transmission_1: ~ /media : cp /media/ca.crt /usr/local/etc/openvpn/ca.crt 
    # our pass.txt file we created:
    root@transmission_1: ~ /media : cp /media/pass.txt /usr/local/etc/openvpn/pass.txt
    # Finally renaming the <Server>.ovpn file to .conf file (You'll have to use "" around the name if there is a space in it.)
    root@transmission_1: ~ /media : cp /media/Your_Selected.ovpn /usr/local/etc/openvpn/openvpn.conf
  22. Start your OpenVPN server:
    root@transmission_1 ~ / : /usr/local/etc/rc.d/openvpn start
  23. Check your install. You should be able to query the VPN tunnel:
    root@tranmission_1: ~ /media : ifconfig tun0 # You should see a printout like:
    # ifconfig tun0
    tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1500
    options=80000<LINKSTATE>
    inet 10.9.0.22 --> 10.9.0.21 netmask 0xffffffff
    nd6 options=1<PERFORMNUD>
    Opened by PID 7036
    # Or something similar...
  24. Congratulations! Your Transmission packets are now using Torguard!
  25. One caveat worth mentioning here:  You probably won’t be able to automagically update the Transmission client from the GUI as I have never been able to get it to successfully update itself. Whether that is the fault of our modifications or just a bug in Freenas I am not sure. To update, just make a note of your Transmission jail’s storage structure and delete the plugin and re-install according to the guide again. It’s a bit of a PITA – but for now, it is the only way.

Not Working? Check out these useful commands and troubleshooting tips.

Useful Open VPN Commands:
#Stop openvpn
root@transmission_1: ~ / : /usr/local/etc/rc.d/openvpn stop

#Start openvpn
root@transmission_1: ~ / : /usr/local/etc/rc.d/openvpn start

#Restart openvpn
root@transmission_1: ~ / : /usr/local/etc/rc.d/openvpn restart

#Query Secure network VPN tunnel
root@tranmission_1: ~ / : ifconfig tun0

#Query whole Freenas network
root@transmission_1: ~ / : ifconfig

# stop all openvpn processes
root@transmission_1: ~ / : killall -TERM openvpn

Still not working as you expect? Check out the log files in Freenas before you post a comment.

#Check log files for clues
root@transmission_1: ~ / : less /var/log/messages
root@transmission_1: ~ / : less /var/log/messages
root@transmission_1: ~ / : more -f /var/log/messages
root@transmission_1: ~ / : cat /var/log/messages
root@transmission_1: ~ / : tail -f /var/log/messages
root@transmission_1: ~ / : grep -i error /var/log/messages **This one is good as it will filter the log for error messages.

Still not working? Check this post for clues (it’s a good troubleshooting primer as well).  Just telling me it’s not working does not provide enough information to troubleshoot your problem. You wouldn’t take your car into the garage and say, “my car doesn’t work!” – you need to give me some clues to help you fix your problem. Check your steps carefully, every command has to be issued as it is shown in the how to.  If you find any mistakes please let me know and I will fix them right away.

46
Leave a Reply

avatar
22 Comment threads
24 Thread replies
1 Followers
 
Most reacted comment
Hottest comment thread
18 Comment authors
RickErickRicAndrewNorah Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Dane Nguyen
Guest
Dane Nguyen

Where did you find the crl.pem file? all i have is a ca.crt and a lot of ovpn’s. When i run /usr/local/etc/rc.d/openvpn start i get Starting openvpn. then nothing. i check ifconfig and does not show tun0

Mark
Guest
Mark

Great guide, works awesomely with TorGuard 🙂

Thankyou

Nick
Guest
Nick

Followed your guide and it works great, but I’m having issues with transmission claiming its port is closed despite being forwarded on my router. Do I have to request the port forward with torguard directly and which IP do I provide? For example, you show 10.9.0.22 –> 10.9.0.21. Would I use .22 or .21?

Philip
Guest
Philip

Hi. Did you ever get a response to this? I have an issue with the Transmission port being closed despite it being referenced in my firewall port forwarding.

Moandain
Guest
Moandain

portmap_enable=”NO”
sshd_enable=”NO”
sendmail_enable=”NO”
sendmail_submit_enable=”NO”
sendmail_outbound_enable=”NO”
sendmail_msp_queue_enable=”NO”
hostname=”transmission_1″ devfs_enable=”YES”
devfs_system_ruleset=”devfsrules_common”
transmission_download_dir=””
transmission_enable=”YES”
transmission_conf_dir=”/var/db/transmission”
openvpn_enable=”YES”
openvpn_configfile=”/usr/local/etc/openvpn/openvpn.conf”

did I do something wrong in the rc.conf?

Moandain
Guest
Moandain

/usr/local/etc/rc.d/openvpn: WARNING: ”/usr/local/etc/openvpn/openvpn.conf” is n
ot readable.
/usr/local/etc/rc.d/openvpn: WARNING: failed precmd routine for openvpn
root@transmission_1:/ #

this is what I get every time.

Moandain
Guest
Moandain

YAY for dumb mistakes in my rc.conf file

Adam
Guest
Adam

I’m getting the same error. What mistakes did you make in rc.conf file?

Adam
Guest
Adam

I found another command to start openvpn: /usr/local/etc/rc.d/openvpn start – gave me the same error but using /usr/local/etc/rc.d/openvpn onestart worked. I just have to remember to run this every time I reboot server.

Josh
Guest
Josh

Just as note I had a previous setup from Torguard blog that worked initially but then would die after a while and not come back. So using this guide does work, but I did have to reboot the server to get openvpn to open tun0 in my jail.

One thing you can add though is from this thread take his firewall rules and everything but transmission traffic goes out the tun. You do lose the possibility of remote transmission access but I also run flex get in my transmission jail so it uses normal pathway.

https://www.reddit.com/r/freenas/comments/41fhz3/configuration_guide_for_openvpn_and_ipfw_so_that/

Ric
Guest
Ric

root@transmission_1:/ # pkg install bash

Operation timed out repository FreeBSD has no meta file, using default settings

Wilson
Guest
Wilson

Thanks for the write up…saved me a lot of time 🙂

Erick
Guest
Erick

I’shaving a problem starting the vpn. I get this message when i check the logs

“transmission_1 openvpn[55027]: Options error: You must define TUN/TAP device (–dev)”
any help would be appreciated!

Ray
Guest

I trying to get this installed. When trying to start OpenVPN /usr/local/etc/rc.d/openvpn start
I don’t have the openvpn in the rc.d folder.

Rohit Pawar
Guest
Rohit Pawar

I got the same error, you would need to install the OpenVPN package manually first along with the bash and nano packages mentioned earlier in the article. Took a while to figure out, but it works great after that.

eric
Guest
eric

Cant seem to get the service to start.

root@transmission_1:/ # /usr/local/etc/rc.d/openvpn start
/usr/local/etc/rc.d/openvpn: Command not found.
root@transmission_1:/ # cd /usr/local/etc/rc.d
root@transmission_1:/usr/local/etc/rc.d # ls
pbid svnserve transmission
root@transmission_1:/usr/local/etc/rc.d #

Any help would be great.

Mikcey
Guest
Mikcey

After about 3 years of use I am so disappointed in freenas, cannot wait to go back to linux.

Ercik
Guest
Ercik

I have done this tutorial many times over the last year with great success, but today this happened. can anyone help with this? # make install clean ===> Building/installing dialog4ports as it is required for the config dialog ===> Cleaning for dialog4ports-0.1.6 ===> Skipping ‘config’ as NO_DIALOG is defined /!\ ERROR: /!\ Ports Collection support for your FreeBSD version has ended, and no ports are guaranteed to build on this system. Please upgrade to a supported release. No support will be provided if you silence this message by defining ALLOW_UNSUPPORTED_SYSTEM. *** Error code 1 Stop. make[3]: stopped in /usr/ports/ports-mgmt/dialog4ports ***… Read more »

Ric
Guest
Ric

# make install clean command throws me an error! Please HELP! root@transmission_1:/usr/ports/security/openvpn # make install clean ===> Building/installing dialog4ports as it is required for the config dialog ===> Cleaning for dialog4ports-0.1.6 ===> Skipping ‘config’ as NO_DIALOG is defined /!\ ERROR: /!\ Ports Collection support for your FreeBSD version has ended, and no ports are guaranteed to build on this system. Please upgrade to a supported release. No support will be provided if you silence this message by defining ALLOW_UNSUPPORTED_SYSTEM. *** Error code 1 Stop. make[3]: stopped in /usr/ports/ports-mgmt/dialog4ports *** Error code 1 Stop. make[2]: stopped in /usr/ports/ports-mgmt/dialog4ports ===> Options unchanged… Read more »

Norah
Guest
Norah

Successfully get the VPN up and running. However, the tun0 eventually died afterward. I have to restart the jail via freenas GUI and the tune0 up again. Anyways, how can I fix this?

Andrew
Guest
Andrew

What is “tsch”?

Andrew
Guest
Andrew

Steps 16-21 Seem out of order/missing appropriate instructions. Please advise.

Ric
Guest
Ric

I am getting the following error message when trying to run “make install clean” command: (Step 11. Make a clean install which allows us to set the option of a password file.) I have the latest “Transmission version 2.93-amd64” (Freenas build 11.1-U5). Please advise. root@customplugin_1:/usr/ports/security/openvpn # make install clean ===> Building/installing dialog4ports as it is required for the config dialog ===> Cleaning for dialog4ports-0.1.6 ===> Skipping ‘config’ as NO_DIALOG is defined /!\ ERROR: /!\ Ports Collection support for your FreeBSD version has ended, and no ports are guaranteed to build on this system. Please upgrade to a supported release. No… Read more »

Erick
Guest
Erick

I just installed the freenas 11.2 beta, are the commands the same for iocage jails? It would not install nano so i am stuck at that point in my installation..

Erick
Guest
Erick

i got everything installed but my ip address in still my home ip not the vpn ip. i noticed when i did ifconfig tun0 command this line was missing.
inet 10.9.0.22 –> 10.9.0.21 net mask 0xffffffff
any ideas.

Erick
Guest
Erick

“ifconfig: interface tun0 does not exist.” after following the instruction to a tee. it says open vpn is starting then this..

Erick
Guest
Erick

“root@transmission /media]# grep -i error /var/log/messages
Oct 23 08:35:08 transmission openvpn[59797]: Exiting due to fatal error” when i enter this command…

Erick
Guest
Erick

[root@transmission /media]# cat /var/log/messages Oct 22 23:21:56 transmission newsyslog[31526]: logfile first created Oct 22 23:21:56 transmission syslogd: kernel boot file is /boot/kernel/kernel Oct 22 23:22:00 transmission pkg-static: pkg-1.10.5_3 installed Oct 22 23:22:00 transmission pkg-static: pkg reinstalled: 1.10.5_3 -> 1.10.5_3 Oct 22 23:22:07 transmission pkg: libnghttp2-1.33.0 installed Oct 22 23:22:07 transmission pkg: ca_root_nss-3.39 installed Oct 22 23:22:07 transmission pkg: indexinfo-0.3.1 installed Oct 22 23:22:07 transmission pkg: miniupnpc-2.1_1 installed Oct 22 23:22:07 transmission pkg: bittorrent-libutp-0.20130514_1 installed Oct 22 23:22:07 transmission pkg: libnatpmp-20150609 installed Oct 22 23:22:08 transmission pkg: curl-7.61.1 installed Oct 22 23:22:08 transmission pkg: libevent-2.1.8_2 installed Oct 22 23:22:08 transmission pkg:… Read more »