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.

Set up IPsec

Important

IPsec support is an alpha feature and is not suitable for production deployments.

Fast Path Provider (FPP) 3.2.0 lets a Connectivity Gateway (CGW) terminate IPsec tunnels. strongSwan 6.1 charon runs as a VPPTool next to Vector Packet Processing (VPP) and negotiates the tunnels with Internet Key Exchange (IKE). Its vpp_sswan backend installs the Security Associations (SAs) in VPP, so VPP encrypts and decrypts the traffic in the Data Plane.

The integration supports:

  • IKEv1 and IKEv2
  • IPv4 and IPv6, for both the tunnel traffic and the underlay
  • Mixed IP versions, IPv4 over IPv6 and IPv6 over IPv4, in route-based mode only
  • NAT traversal (NAT-T), with limitations
  • Tunnel mode and transport mode
  • Pre-shared keys and certificates
  • Prometheus metrics for IKE_SAs, CHILD_SAs, and certificates

An IKE_SA is the authenticated channel between the two peers. A CHILD_SA is the pair of SAs that carries the traffic.

Prerequisites

Before you set up IPsec, make sure that you have:

  • VPP Operator 3.2.0, upgraded as described in 3.1.0 → 3.2.0
  • A CGWDeployment on the FPP 3.2.0 revision of the cgw-generic Composition

Route-based and policy-based mode

vpp_sswan supports two modes. A CHILD_SA selects the mode with its if_id. The following table compares the two modes:

Use route-based mode unless the peer requires otherwise. Route-based mode avoids most of the limitations of policy-based mode. It also lets a routing protocol such as Border Gateway Protocol (BGP) run through the tunnel.

Caution

In policy-based mode, once the first CHILD_SA is up, VPP drops all outbound traffic on the underlay interface unless the traffic matches a CHILD_SA. This includes the traffic of the CGW itself, for example routing protocols. After a VPP restart, VPP sends LAN traffic to the remote subnets without encryption until charon installs the first CHILD_SA.

Create the VPPTool resources

Create the tools that negotiate the tunnels and export their metrics, and the Secret with the pre-shared key.

Caution

Modifying a VPPTool object restarts all FPP pods that use it, which causes network downtime.

  1. Create the charon VPPTool in the Core Cluster. The image ships with FPP and uses the FPP version as its tag:

    yaml

    The following rules apply to the charon definition:

    • The container must be privileged, because the tool starts charon in the Linux Control Plane (LCP) network namespace.
    • shm and run are volumes of the FPP pod. Do not declare them in spec.volumes.
    • Keep secrets out of the CGWDeployment. Mount them as a Secret in /etc/swanctl/conf.d. Mount certificates and keys in /etc/swanctl/x509 and /etc/swanctl/private.
    • With canReload: true, a change of swanctl.conf reloads the configuration without a restart of the pod.
  2. Create the Secret with the pre-shared key in the namespace of the CGW:

    yaml
  3. (Optional) To export IPsec metrics, create the ipsec-exporter VPPTool. It reads the state of charon through the VICI socket in the shared vici volume:

    yaml

The Core Cluster now has the tools and the Secret that the CGWDeployment refers to.

Configure the CGWDeployment

Add the IPsec configuration to a CGWDeployment.

  1. Write a CGWDeployment manifest with the IPsec configuration. The following example sets up a route-based tunnel between two local area networks (LANs). The tunnel connects 10.81.0.0/24 behind CGW cgw-a with 10.82.0.0/24 behind the peer at 10.80.0.2:

    yaml
  2. Apply the CGWDeployment on the Management Cluster:

    Caution

    If you apply this configuration to an existing CGW, the CGW pods restart, and traffic through the CGW stops until the pods are ready.

    bash

The CGW pod starts with the tool-charon container, and charon starts the tunnel.

The ipsecTunnel interface

A VPPInterface with spec.ipsecTunnel creates a VPP IPsec tunnel interface. vpp_sswan attaches the SAs of a CHILD_SA to the interface whose spec.ipsecTunnel.instance equals the if_id of the CHILD_SA.

The tunnel interface has the following requirements:

  • spec.ipsecTunnel.instance must be from 1 to 16383 and unique in the CGW. If two VPPInterface resources request the same instance, the oldest one uses it, and the others stay not ready with a Warning event.
  • The interface needs an IP address of each IP version that the tunnel carries. VPP drops decrypted packets of an IP version that is not enabled on the interface.
  • Set the maximum transmission unit (MTU) at least 101 bytes below the MTU of the underlay, or 121 bytes for an IPv6 underlay. Otherwise VPP drops large packets after encryption.
  • The interface and the LAN can use a different table than the underlay. VPP sends the Encapsulating Security Payload (ESP) packets in the table of the underlay.
  • Without an established CHILD_SA, the interface drops all traffic.
  • The route to the IKE address of the peer must not go through the tunnel interface.

swanctl.conf rules

Follow these rules in swanctl.conf:

  • Set local_addrs to the underlay address. vpp_sswan uses it to find the interface and table of the SAs.
  • In route-based mode, set the following CHILD_SA options:
    • if_id_in and if_id_out to the same value
    • policies = no
    • start_action = start
  • Use one CHILD_SA for each if_id.
  • For policy-based mode, omit if_id_in, if_id_out, and policies. Add a route to the remote LAN through the underlay interface. VPP routes decrypted packets in the table of the underlay, so also add a route in that table back to the LAN interface.
  • charon does not install routes. Configure them with spec.routingTables.
  • Run only one charon per CGW. When charon starts, it removes all IPsec objects from VPP. For this reason, do not create IPsec objects with beforeCommands or afterCommands of a VPPConfig.

IPsec metrics

Set spec.ipsec.metricsEnabled to true to expose the ipsec-exporter metrics on port 9536 of the CGW Service. The fpp-support CGW ServiceMonitor scrapes this port when spec.cnfName is cgw.

The ipsec-exporter metrics are the same as in CGW 1.x. For the list of metrics, see IPsec Exporter metrics in the CGW documentation and IPsec metrics.

CGW 1.x Grafana dashboard

The IPsec metrics of an FPP CGW work with the CGW Overview Grafana dashboard of the CGW 1.x cgw-support chart. The CGW ServiceMonitor adds the app: cgw and release: {POD_NAME} labels that the dashboard filters on, so its IPsec panels show FPP CGW tunnels without changes. For a description of the panels, see the CGW Grafana dashboard documentation.

Restart behavior

If VPP or charon restarts, the tool starts a new charon that clears the old SAs and negotiates all tunnels again. The tunnels are down until charon installs the new CHILD_SAs. During this time, route-based tunnels drop the LAN traffic. In policy-based mode, the LAN traffic can leave unencrypted after a VPP restart, until charon installs the first CHILD_SA.

A CHILD_SA without start_action = start stays down until the peer initiates it again.

Limitations

IPsec support in FPP 3.2.0 has the following limitations:

  • Use each local IKE address on only one VPP interface. If two interfaces have the address, vpp_sswan uses the first one.
  • VPP does not check the traffic selectors of decrypted traffic. If the underlay network is not trusted, add an input VPPACL on the IPsec tunnel interface that permits only the peer subnets. This applies to route-based mode.
  • NAT-T works only if the NAT in front of the peer keeps the peer's ports 500 and 4500, for example with a static port mapping. VPP always sends ESP-in-UDP packets to port 4500 of the peer.
  • Each stop of the CGW pod logs a FailedPreStopHook warning event for the ipsec-exporter container, because its image has no shell. The event has no effect on the pod.
  • In policy-based mode:
    • Inbound IPv4 over IPv6 and IPv6 over IPv4 traffic does not reach the LAN, because VPP drops it. Use route-based mode for these combinations.
    • VPP does not drop unencrypted inbound packets that match a protected subnet.
    • Once the first CHILD_SA is up, VPP drops all other outbound traffic on the underlay interface, including the CGW's own traffic. Send other traffic through an interface without IKE.
    • VPP drops ESP packets that arrive as IP fragments. As a workaround, add set interface reassembly {{ .Ifs.underlay.Name }} ip4 to the afterCommands of a VPPConfig.
    • If a packet with the Don't Fragment (DF) bit is too large after encryption, VPP drops it. The sender gets no Internet Control Message Protocol (ICMP) message. Clamp the TCP maximum segment size (MSS) on the LAN side, or set copy_df = no for the CHILD_SA.
    • LAN traffic that is itself IPsec, such as ESP, Authentication Header (AH), or IKE on UDP port 500 or 4500, bypasses the tunnel.
    • Transport mode does not support NAT-T over IPv6. Use tunnel mode if NAT-T is necessary.

Verification

Check the SAs in the tool-charon container:

bash

Sample output for the tunnel of the CGWDeployment example:

text

The IKE_SA must be ESTABLISHED, and the CHILD_SA must be INSTALLED.

Check that VPP attached the SAs to the tunnel interface:

bash

Sample output for the tunnel interface vti of the same tunnel:

text

The tunnel interface must list an output SA and an input SA with the Security Parameter Indexes (SPIs) that swanctl --list-sas shows.

If the tunnel interface does not exist yet, the charon log shows interface ipsec<if_id> not found, its SAs wait for it. vpp_sswan attaches the SAs as soon as the interface appears.