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.

Policy-based and route-based VPN

Policy-based VPN

By default, strongSwan and the older models of IPsec VPNs use the policy-based routing mode.

As the name suggests, the corresponding software, in this case strongSwan, adds policies into the kernel. These polices either match your packets and therefore encrypt them and send them over the tunnel to the right destination, or they do not match the packets and therefore don't touch them at all.

On Linux machines, you can see the installed policies using the following command:

sh

Output example:

text

These three policies depend on their direction as mentioned in lines 2, 6, and 10. When the source and the destination addresses match the corresponding source and destination range, the packets are treated with the protocol defined in lines 4, 8, and 12 – in this case Encapsulating Security Payload (ESP).

This is commonly used for VPN because no routes have to be set or agreed on.

Route-based VPN

Route-based VPN uses a virtual interface called Virtual Tunnel Interface (VTI). In the case of Linux, this is actually implemented like a tunnel and, from the user perspective, looks like other tunnels, including GRE and VXLAN.

This tunnel interface can therefore be used to route traffic over this interface. Every packet which reaches the interface is marked by the kernel number. After that, the packet is matched by the XFRM rule and therefore encrypted and sent to the other IPsec Gateway.

Comparing to the policy-based VPN, the configuration of a route-based VPN is a bit more complicated because of the created tunnels and routes. The benefit of this solution is that also other routing mechanisms are working over the VPN tunnels, for example BGP and OSPF. That's why it is possible to create high available architectures with failover between tunnels.

Due to these reasons, route-based VPN is the preferred way of setting up VPNs at Travelping.

For further information, read the strongSwan documentationOpens in a new tab.

Caveat with VTI

As described above, in the case of Linux, VTIs are not implemented as special interfaces, like in some other operating systems, but as virtual tunnels.

Therefore, use the following command:

sh

For debugging purposes, set <local IP> and <remote IP> to the same IP as used in the VPN configuration.

To route traffic over to the VTI, assign a network and an IP address to VTI. If the address 2001:db8:100::0/127 is assigned to the vti1 interface, the corresponding routes are set as follows:

sh

In this example, it doesn't matter which IP addresses are used, as long as they do not interfere with the ones already used in the network. Because the packets are marked when going through VTI and the Ethernet header is removed, the IP address of the other side, in this case 2001:db8:100::1/127, does not need to exists on the other end and is just virtual to us.