For a small number (less than four) of fixed endpoints, a point-to-point setup is very flexible. In this recipe, we set up three OpenVPN tunnels between three sites, including routing between the endpoints. By setting up three tunnels, we create a redundant routing so that all sites are connected even if one of the tunnels is disrupted.
We use the following network layout:
Install OpenVPN 2.0 or higher on two computers. Make sure the computers are connected over a network. In this recipe, the tunnel endpoints were running CentOS 5 Linux or Fedora 13 Linux and OpenVPN 2.1.1. Make sure that the routing (IP forwarding) is configured on all the OpenVPN endpoints.
We generate three static keys:
Transfer these keys to all endpoints over a secure channel (for example, using scp
).
Create the server (listener) configuration file named example1-8-serverBtoA.conf
:
First, we start all the listener tunnels:
These are followed by the connector tunnels:
And with that, our three-way site-to-site network is established.
It can clearly be seen that the number of configuration files gets out of hand too quickly. In principle, two tunnels would have been sufficient to connect three remote sites, but then there would have been no redundancy.
With the third tunnel and with the configuration options:
There are always 2 routes to each remote network.
For example, site A has two routes to site B (LAN 192.168.5.0/24), as seen from the following routing table:
A route:
Via the "direct" tunnel to site B; this route has the lowest metric
Via an indirect tunnel: first to site C and then onward to site B; this route has a higher metric and is not chosen until the first route is down
This setup has the advantage that if one tunnel fails, then after 60 seconds, the connection and its corresponding routes are dropped and are restarted. The backup route to the other network then automatically takes over and all three sites can reach each other again.
When the "direct" tunnel is restored the direct routes are also restored and the network traffic will automatically choose the best path to the remote site.
In this recipe, we connect three remote sites. This results in six different configuration files that provide the limitations of the point-to-point setup. In general, to connect N possible sites with full redundancy, you will have N * ( N – 1 ) configuration files. This is manageable for up to four sites, but after that, a server/multiple-client setup as described in the next chapters is much easier.
To increase the availability of the networks, it is better to run a Routing Protocol such as RIPv2 or OSPF. Using a routing protocol, the failing routes are discovered much faster, resulting in less network downtime.