Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a VPS that I want to connect to from my home machine via OpenVPN, but I also want that VPS to connect to another OpenVPN server. It ends up looking like this

Home/Road Connection -> OpenVPN VPS -> 2nd OpenVPN provider

The first two steps are simple; but how can I setup the VPS so that it hosts an OpenVPN server for my first connection, and then setup another instance of OpenVPN on the VPS so it routes all traffic to that second OpenVPN server?

share|improve this question

This is actually very simple... You just need to add a client config to the server so that it will initiate it's client VPN connection to your 2nd provider.

You don't mention what OS you're running, but I am working from Ubuntu with both my client machines and my server. In Ubuntu the SysV init script looks for all /etc/openvpn/*.conf files if you set AUTOSTART to all in the /etc/default/openvpn config file. OpenVPN doesn't care if these *.conf files are client or server configuration it just executes them.

share|improve this answer
I'm using Ubuntu on the client and server as well. Just to clarify; Add the client config (and certs and all that) to the OVPN's folder, and then just change AUTOSTART to all in the openvpn config? No need to enable ip_forwarding or make an iptables rule to forward all traffic from the first tun to the second tun device? – noctorum Aug 19 '11 at 23:23
I'm pretty sure you'll need ip forwarding to be turned on, since you're going from one interface to another one (e.g., tun0 to tun1). You may want to assign different IP ranges between the two separate openvpn networks, e.g., 10.8.1.x to your road network, and 10.8.2.x to the other one, mainly to keep things clean. After that, you'll need to set up routing so that your road connection knows to use the VPS hop to route. – cjc Aug 20 '11 at 0:04
I believe you'll need IP forwarding enabled to have the server act as a router and pass the traffic along through the interfaces. I know that my VPN clients connecting to the server don't need IP forwarding to communicate between one another but that's all over the same interface. – Jeremy Bouse Aug 20 '11 at 11:55 This lovely page here walks you through doing what you require. There should be no special magic to it.

There is a script example that will also create virtual devices and bridge them if that's what you require.

You can simply do openvpn client.conf to connect and as stated by Jeremy, anything in /etc/openvpn/*.conf will get executed automatically at startup.

for redirecting all traffic through your vpn connection:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.