For AI agents: this documentation is indexed for you in llms.txt, and all of it in /llms.txt. Every page is also available as markdown: append .md to its address.

You are reading Connectivity Gateway 1.7, an older release. The newest release is 1.12. Read this page in 1.12

Set up a route-based VPN

This tutorial uses the result of the Policy-based VPN tutorial as a starting point. If you did not went through this tutorial first, please do so.

Current configuration

This is the resulting configuration from the policy-based tutorial. We will change this further to get to a working configuration with the route-based VPN.

yaml

Changes to strongSwan

We will use a Virtual Tunnel Interface (VTI) as a target for routing through the tunnel. Change the configuration as follows:

yaml

If you have multiple VPN connections, make sure that the numbers used as a value for the mark parameter are unique to this configuration.

Subnets

In the case of a route-based VPN, it is common to set both subnets to ::/0 or 0.0.0.0/0, and decide based on the routes which traffic to send over link. Therefore, we will change the networks to the following:

yaml

Often other routers do not accept the setting, so it makes sense to restrict the networks further as in the starting configuration on the top.

Setting up VTIs

To route traffic over the VPN connection, you must create a VTI. As described in the tutorial for imperative IP configuration, use the init script:

yaml

In the env section of the initscript, we will define our parameters as environmental variables, as it eases reusability and increases readability.

The value MARK is used to the define, what key will be set for the packets traversing the interface. This values has to be the same as the one configured in the strongSwan section before.

LEFT_ENDPOINT and RIGHT_ENDPOINT are the endpoints of the VPN connection as configured in the strongSwan section.

VIRTUAL_ADDRESS_LEFT_CIDR and VIRTUAL_ADDRESS_RIGHT_CIDR are two IP addresses, which will be used for routing descisions by the kernel. As these IP addresses will not be seen on the other side, you just have to use them out of a range, which is not used in you network already. In this case we use ULA IP addresses.

As shown in line 16, we create the VTI interface as a virtual tunnel interface with the actual endpoints of the tunnel. Further the key parameter is here set to the value of MARK.

We add the virtual IP address for routing to the interface in line 17.

Last, we enable the tunnel by setting it in the up state.

Add routes

To transfer traffic over the tunnel, add targets and their routes to the routing table. First, add the following variable to the configuration (line 12 in the configuration above):

text

Second, add the following routes at the place marked above in line 19:

text

This setting sends the traffic with target of 2001:db8:10::/48 over the VPN tunnel. The right endpoint does not need to have the address assigned to an interface, as it is just virtual on our side.