OpenVPN

There are two main types of VPN connections supported by linux, PPTP and OpenVPN. For simplicity we're going to focus on OpenVPN. This tutorial assumes that you have a VPN service that provided you with a config file, and either a username and password, a CA certificate, or both.

I personally use privateinternetaccess.com ($6.95/month), but there are some free ones available (vpnbook.com for example) that you can use for this tutorial if you don't want to sign up for a paid VPN right away.

Install OpenVPN:

sudo apt-get update
sudo apt-get install openvpn

Create a script to kick off your vpn connection and make it executable:

cd ~/
touch vpn.sh
chmod +x vpn.sh

Now edit your vpn.sh script to look like this:

#!/bin/sh
sudo openvpn --config /path/to/your/openvpn/config/file --script-security 2

Now you should be able to execute this script to connect to your vpn:

./vpn.sh

It will most likely prompt you for your username and password, and then you will be connected to the VPN and all of your traffic should tunnel through there.

How do I know I'm connected to the VPN? - An easy way to check that you are connected to your VPN is to point your browser at https://duckduckgo.com/?q=ip before and after you connect to your VPN. This pag will show you what your current ip address is, and it should be different when you are connected to the VPN than it is when you are not.

You can also check your ip address from the command line using this command:

curl ifconfig.me/ip

comments powered by Disqus