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 ($6.95/month), but there are some free ones available ( 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 ~/
chmod +x

Now edit your script to look like this:

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:


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 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:


comments powered by Disqus