> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/cgw/1.7/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/cgw/1.7/concepts/models/s2s-route-based-vpn.md).

# Site-to-site route-based VPN using IPsec

The picture presents the overall architecture of the site-to-site route-based VPN model and
the functions on each part.

![overview](https://docs.cennso.com/api/assets/components/cgw/1.7/resources/images/s2s-route-based-vpn-1.svg)

### Protocol over the Internet

As shown in the picture above, the architecture of a simple VPN connection
consists of two sides, ours (left) where the CGW is implementing the
functionality, and the other side (right).

The link `L3` connects both sides over a network or Internet.
On both sides, the function to connect them is a VPN concentrator (`C3`
and `C4`).

The protocol stacks can be different depending on the circumstances.

In general, all key management is handled by the IKE protocol.
Over this protocol, the keys are exchanged, the cyphers are selected, and the encapsulated networks
are chosen.

![IKE](https://docs.cennso.com/api/assets/components/cgw/1.7/resources/images/s2s-route-based-vpn-L3.svg)

After the connection setup, the IP traffic is encrypted and sent over
the tunnel between the two concentrators.

![ESP](https://docs.cennso.com/api/assets/components/cgw/1.7/resources/images/s2s-route-based-vpn-L3-ESP.svg)

In the case of a public IP address of the concentrators and no filters in
between, the ESP packet is directly transferred as an IP payload, whereas it
is encapsulated by UDP in the case NAT is detected or a direct connection is
not working.

![ESP-UDP](https://docs.cennso.com/api/assets/components/cgw/1.7/resources/images/s2s-route-based-vpn-L3-ESP-UDP.svg)

### CGW internal functions

As presented in the graph below, CGW implements multiple functions in one pod and
therefore also on one network namespace.

![CGW detail](https://docs.cennso.com/api/assets/components/cgw/1.7/resources/images/s2s-route-based-vpn-2.svg)

CGW implements two interfaces to connect to both sides.
One is a **VXLAN** interface that is normally managed by the VXLAN Controller.
It creates a virtual Ethernet segment between the connected pods.
In the graph, it is shown as a switch (`C1`).

The second interface is the Virtual Terminal Interface (VTI).
It only exists if the [route-based VPN](https://docs.cennso.com/components/cgw/1.7/concepts/policy_route_based_vpn.md)
is chosen as the mode for VPN.

VTI implements a virtual tunnel interface.
The tunnel is virtual in the sense that there are no tunnel protocols run on
link `L4`. Nevertheless, both sides of the virtual tunnel have an IP address.
The one of one side can then be used to route traffic to the other side by
utilising the routing functionality of the Linux kernel.

To route traffic from VXLAN to VTI, add routes for the other side of the VPN tunnel to the routing table manually.
Then, configure the routes in all pods or add CGW as the default router.

>**NOTE:** In case of IPv6, Router Advertisement can be used to announce the routes to
other pods in the VXLAN networks.
