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.6, an older release. The newest release is 1.12. Go to 1.12

Route-based VPN

If you have not already read up on the differences between route-based and policy-based VPN, please do so.

We will use the result of the tutorial on policy based vpn as a starting point. So if you did not went through this tutorial first, please do so.

current configuration

yaml

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

Changes to Strongswan

As described in the concepts, we will use a Virtual Tunnel Interface (VTI) as a target for routing through the tunnel. Change the Configuration as follows:

yaml

mark sets the value used to mark the packets to use in conjunction with a Virtual Tunnel Interface.

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

subnets

In the case of 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 will not accept the setting though, and therefore it can make sense to restrict the networks further as in the starting configuration on the top.

setting up VTI interfaces

To route traffic over the VPN connection, a VTI interface has to be created. As described in the tutorial for imperative IP configuration, we will do so using 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 be able to transfer traffic over the tunnel, we have to add targets and its routes to the routing table.

First we will add the following variable to the configuration (line 12 in the above config):

text

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

text

This setting will now send the traffic with target of 2001:db8:10::/48 over the VPN tunnel. As described in the concepts, the right endpoint does not need to have the address assigend to an interface, as it is just virtual on our side.