Using a VPN on OpenELEC is something that many people find is necessary because they want to either unblock geo-restricted material or they want to make sure their ISP or anyone else can’t see what they are doing online. Follow along to see how you can use IPVanish with your OpenELEC Kodi HTPC.
Before we start there are a few pre-requisites you need in order for this to work correctly.
- IPVanish Account – You will need this as your VPN provider. They’re the only Tier-1 premium bandwidth VPN company and their service is amazing. They have over 225 servers in 60+ counties. They keep no logs and are 100% anonymous.
- SSH Client – I use and recommend PuTTY – Look for ‘putty.exe’ and save that somewhere
- The IP of your OpenELEC HTPC. You can get this by going to System -> Hardware -> Summary and looking for ‘IP Address’. Make note of this.
So lets start by logging into your IPVanish account and grabbing the OpenVPN config files. You will need a few files included in the zip, but not every single one of them. Once you login click on Server List, the click OpenVPN to download ‘configs.zip’
Since you can only be connected to one VPN server at a time, we can actually remove all the .ovpn files except for one. What I recommend doing is choosing a VPN profile that is in the same state/country you are in so that you’ll get the best speed possible. That, or if you are looking to unblock geo-restricted content, then choose the country that is unblocked. Seeing as how I am in Canada, I use a VPN server in the USA to watch USA based content that is blocked for Canadians.
Now that we have those two files, we need to make some modifications so that it will work with OpenELEC. First thing we need to do is modify the .ovpn file. If you see anything you’re unsure about (file paths, names etc) it should all make sense and come together at the end. Open it up in notepad (or TextPad or Notepad++) and make the following changes:
- Change the 4th line – ‘remote ipvanish.server 443’ to ‘remote ipvanish.server 1194’
- Change the 10th line – ‘ca ca.ipvanish.com.crt’ to ‘ca /storage/.config/vpn-config/ca.ipvanish.com.crt’
- Change the 12th line – ‘auth-user-pass’ to ‘auth-user-pass /storage/.config/vpn-config/pass.txt’
- The steps below are optional, they’re needed if you’re experiencing slowness (this lowers the encryption)
- Comment out line 18 – So put a ‘#’ at the start of the line
- On line 19 (under the line we just commented out) put the following – tls-cipher DHE-RSA-AES128-SHA
Your config when finished should look like the following:
client dev tun proto udp remote ipvanish.server 1194 resolv-retry infinite nobind persist-key persist-tun persist-remote-ip ca /storage/.config/vpn-config/ca.ipvanish.com.crt tls-remote ipvanish.server auth-user-pass /storage/.config/vpn-config/pass.txt comp-lzo verb 3 auth SHA256 cipher AES-256-CBC keysize 256 #tls-cipher DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA tls-cipher DHE-RSA-AES128-SHA
Note that if you copy and paste that, it won’t work. I’ve removed the server addresses.
Once you have saved that the next step is to create a file called ‘pass.txt’ that has the following 2 lines:
That’s it. All you need in there is your IPVanish username and password, each on it’s own line.
At this point you should have the following 3 files in your directory:
Now what we’ll need to do is copy these 3 files on to our OpenELEC Kodi box. There is a wiki page here outlining how you can connect to the Samba shares on your OpenELEC machine – http://wiki.openelec.tv/index.php/Accessing_Samba_Shares. Since I’m on Windows I just need to open up a Windows Explorer window and type \\IP.Address\ and press enter. The IP address is the IP I gathered earlier (from the pre-requisites!)
Once that is open, navigate to \\IP.Address\Configfiles\vpn-config and copy our 3 files there.
Excellent! We’re almost there.
Next up is we need to test our VPN connection to make sure it’s working correctly before we continue on. Let’s fire up our SSH client PuTTY or whatever you choose. Enter in the IP of the OpenELEC machine in the ‘Host Name’ field and click Open.
When you get the login prompt use the following credentials:
- Username: root
- Password: openelec
Now don’t be freaked out by the linux terminal. We’re not doing anything crazy here 🙂
Let’s first navigate to where we saved those three files earlier.
Type the following and press enter:
Once you do that you can type ‘ls’ and press enter to see if they’re all there.
Great, looking good so far.
Let’s do a quick little test to see what our current IP is, so we can test it against the new one to make sure we’re connected.
Type the following and press enter:
It should print out an IP address. That should be your current external IP. It will be the same as if you went to whatismyip.com or something similar.
Now let’s connect to the VPN manually to ensure everything is working. From the command line (and from the directory we changed to with the ovpn file) we need to run the following:
Type and press enter:
openvpn ipvanish-[server].ovpn &
Note: Please note that you will need to replace the [server] with the actual file name. Also note the ‘&’ at the end, this will allow us to go back to the command line once it’s connected.
A little protip is you can start typing the file name and press the Tab button to autocomplete, so just type ‘ipva’ or something and press Tab to autocomplete the name for you.
Once you see something like this: Sun Oct 25 16:23:00 2015 Initialization Sequence Completed, you can press the Enter key to bring you back to the command line.
Now once again you can type the following and press enter:
It should now be different! You’re now connected to IPVanish on your OpenELEC HTPC!
Start Up Script
So that was fun and all but let’s finish this off properly with adding this to an autostart script that will connect us to the VPN whenever we start OpenELEC Kodi.
From your SSH client type the following and press enter:
Once we’re in the text editor all we need to do is copy in the following script. You can highlight the below script and copy/paste it into Putty. In order to paste, make sure you have the text copied to your clipboard, click on Putty, and right click. This should paste it all into the text editor. From there you will need to modify it slightly to suit your exact .ovpn file.
( openvpn /storage/.config/vpn-config/ipvanish.server.config.file.here.ovpn ) &
Now the final thing to do is to reboot OpenELEC and then re-login to the SSH client and run the ‘curl ifconfig.co’ command again to grab our IP to see if it’s still the VPN IP.
Hope that helps with using a VPN with Kodi. I highly recommend you use one if you’re a big online streamer. The VPN will allow you to view it all anonymously which is becoming more and more important these days. Pay a few dollars a month to protect yourself to ensure you’re never the target of anything. I use it on my home setup and recommend it to everyone.
Let me know how it works out for you in the comments, or if you’re having any issues.