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'd like to connect two remote sites via a secure point to point tunnel. I've been using OpenVPN, but it's a little flakey and really seems to be more for connecting lots of users rather than a point to point link.

Redhat seems to have some nice built in scripts for building Point to Point IPSEC tunnels, but I haven't found anything similar in Ubuntu.

Any guidance on what to use here and how to do it? I'd like to keep it as simple as possible, but still have basic PSK security.

share|improve this question
up vote 3 down vote accepted

Assuming the following network settings:

Your public IP:
Your private network:
Remote public IP:
Remote private network:

1) Install StrongSwan using "sudo apt-get install strongswan"

2) Set up a secret key using "sudo vim /etc/ipsec.secrets": PSK "secret_password"

3) Configure the routes using "sudo vim /etc/ipsec.conf":
conn partner

conn local_to_partner

conn partner_to_local

share|improve this answer

ssh 4.3+ is capable of creating proper VPN tunnels. tun0 and all that.

share|improve this answer
This is pretty awesome. I found a link giving full details. My link is pretty lossy, so I'm going to keep trying to figure out IPSEC, but your answer is great. – Joel K Jan 28 '10 at 16:20
While this is a nice tool and I for one would be playing with this on non production servers. This does bring up the point that one is creating a tunnel through ssh which is layer 7. Thus routing layer 3 packets (ie IP packets) over ssh which is also on top of TCP and again on top of IP adds a lot of overhead that ssh was not originally designed to handle. – Dwight Spencer Apr 22 '15 at 18:09

You can use openVPN to obtain a site to site configuration. You would need to setup each of the Linux machines as routers and create static routes on your internal networks to point to the linux machines. Here is the basic design:

Each local network needs to have its own IP subnet:

Say the IPs are such:
---connected w/ VPN to other network with address


if you create static routes in each of your routers to point to the other LAN you should be able to achieve what you're looking for:
Route on GW1:

Route on GW2:

Then when PC1 pings PC2 the packet will be routed to the default gateway of which will forward it to the linux machine(1.100) which will send it through the tunnel to LAN2.

share|improve this answer
Yeah, this is what I'm doing now. We frequently see the tunnel start to drop traffic. I haven't found any root cause. Traffic outside the tunnel stays clean. I've tweaked OpenVPN settings until the cows come home, but the problem keeps coming back. (UDP and TCP, TCP kernel windowing, UDP transmit windows, compression on/off, keepalives, even using tc to try to give priority to openvpn traffic...) I was hoping for something similar that still gives basic PSK encryption. – Joel K Jan 20 '10 at 16:25
We use OpenVPN successfully between a few remote sites with a fairly simple/plain config. Maybe it's worth posting a separate question to try and debug the OpenVPN flakeyness you're seeing? – James Jan 26 '10 at 17:34
If you haven't moved away from OpenVPN, you may even try using "proto TCP" instead of "proto UDP", there may be some time-out issues between the two sites that will work better with TCP, instead of the "stateless" UDP connection. On a bad connection, I was able to get a more stable tunnel using TCP instead of UDP. – samt Feb 24 '10 at 2:08

You can use SSH's Tunnel feature for that. If you already have SSH set up (very likely) then this will be much easier than the alternatives for just connecting two hosts.

share|improve this answer
I think he wants to tunnel IP, not just a single TCP session. – Michael Graff Jan 20 '10 at 16:24
@Michael Graff: That's what this does. – Peter Eisentraut Oct 19 '10 at 16:36

I would also suggest using SSH tunnels feature. It is easy to set up and since you alluded to running ubuntu, there is even a SSH Tunnel Manager.

share|improve this answer… explains how to set up the proxy and direct firefox and DNS through it. Other programs that support SOCKS proxies should be able to access it as well. This should include your email, IRC, AIM, ICQ the list goes on. – Justin S Jan 20 '10 at 5:38
My understanding is that SOCKS will only work for TCP traffic, and this requires host modification. (the end points aren't actually user hosts, but small linux routers) – Joel K Jan 20 '10 at 16:20
It still may not fit what you need, but SOCKS can handle TCP and UDP traffic. – Justin S Jan 20 '10 at 22:02

Why can't you use what works for Redhat on another linux system? It's not like they're different OSs at heart.

Let me expand on this.

I have used IPSEC to tunnel all traffic between two sites before, and it was not difficult to set up even without tools to do this. If there are scripts that work on redhat, can't you just steal those and run them on your other linux variants? Surely they are not that dissimilar.

share|improve this answer
After you've got about 50 machines, it starts to hurt my old brain to have more than 2 or 3 OSes. :) When everything is the same it also makes debugging a lot easier. – Joel K Jan 20 '10 at 16:22
The redhat scripts are all smashed in with the ifup/ifcfg wrappers and not so easy to port... Still trying. :) But hoping there was a better way. – Joel K Jan 20 '10 at 19:20

I've gotten a lot farther using the openswan and strongswan packages. I still don't have the tunnel up, but these seem to be the tools I want to use. Both are pretty poorly documented, and there seem to be a large number of options with no clear reasons to use one over the other.

So to reframe. has anyone setup openswan/strongswan successfully on Ubuntu using ubuntu debs? Any advice with regard to "IKE vs IKE2", "Encryption method", "PSK configuraton", dynamic port changing, etc.


share|improve this answer

OpenVPN is really one of the most common, best understood and documented methods to link server hosts together like this.

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.