Cascading your VPN connection over multiple hops with Linux

Requirements and preparation

To follow the steps in this How-to, the following requirements must be met. Please see the corresponding documentation if you need help with any of these:

  • OpenVPN is installed
  • You have root access to your computer
  • You have a valid Perfect Privacy account
  • You have downloaded the Perfect Privacy configuration and added the files to /etc/openvpn
# This script can be used as an up and down script for OpenVPN.
# It adds and removes the routes required for a VPN connection 
# cascaded over multiple Perfect Privacy VPN servers.

Get the script on the left, save the file as in you /etc/openvpn/ directory and make it executable with chmod +x /etc/openvpn/

Change into the /etc/openvpn/ directory and issue the following command to establish the connection to the first hop as shown on the left. In this example it will connect to

sudo openvpn --config London.ovpn --script-security 2 --route
remote_host --persist-tun --up --down --route-noexec

If you haven’t configured the VPN configuration file to read your password from a file, you will be asked to provide your Perfect Privacy username and password.


After the connection to the first hop has been established, the script will display the necessary command with all parameters to connect to the second hop. You can copy and paste this line but will need to change <config.ovpn> for the corresponsing configuration file of the server for the next hop.

Now open a new terminal and paste the connection line displayed by the script. Before you press enter, make sure that you replace <config.ovpn> with the location you want to connect to. In this example the second hop is

Once the connection is established the script will show the command for the next hop just like before.

To add a third hop, repeat the previous steps in a new terminal window. In this example we’re continuing the cascade with

If you want, you can add even more hops by repeating the pervious steps once more.

If you have any questions, comments or other feedback regarding this howto, please use the corresponding thread in our community forums.
This website uses cookies to analyze the traffic and to control our advertising. By using this site, you agree to the use of cookies. More information can be found in our privacy policy.