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
CGWDeploymenton the FPP 3.2.0 revision of thecgw-genericComposition
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.
Create the
charonVPPToolin the Core Cluster. The image ships with FPP and uses the FPP version as its tag:yamlThe following rules apply to the
charondefinition:- The container must be privileged, because the tool starts
charonin the Linux Control Plane (LCP) network namespace. shmandrunare 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/x509and/etc/swanctl/private. - With
canReload: true, a change ofswanctl.confreloads the configuration without a restart of the pod.
- The container must be privileged, because the tool starts
Create the Secret with the pre-shared key in the namespace of the CGW:
yaml(Optional) To export IPsec metrics, create the
ipsec-exporterVPPTool. It reads the state ofcharonthrough the VICI socket in the sharedvicivolume: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.
Write a
CGWDeploymentmanifest with the IPsec configuration. The following example sets up a route-based tunnel between two local area networks (LANs). The tunnel connects10.81.0.0/24behind CGWcgw-awith10.82.0.0/24behind the peer at10.80.0.2:yamlApply the
CGWDeploymenton 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
1to16383and unique in the CGW. If twoVPPInterfaceresources 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_addrsto the underlay address.vpp_sswanuses it to find the interface and table of the SAs. - In route-based mode, set the following CHILD_SA options:
if_id_inandif_id_outto the same valuepolicies = nostart_action = start
- Use one CHILD_SA for each
if_id. - For policy-based mode, omit
if_id_in,if_id_out, andpolicies. 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. charondoes not install routes. Configure them with spec.routingTables.- Run only one
charonper CGW. Whencharonstarts, it removes all IPsec objects from VPP. For this reason, do not create IPsec objects withbeforeCommandsorafterCommandsof aVPPConfig.
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_sswanuses the first one. - VPP does not check the traffic selectors of decrypted traffic. If the underlay network is not trusted, add an input
VPPACLon 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
FailedPreStopHookwarning event for theipsec-exportercontainer, 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 }} ip4to theafterCommandsof aVPPConfig. - 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 = nofor 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:
Sample output for the tunnel of the CGWDeployment example:
The IKE_SA must be ESTABLISHED, and the CHILD_SA must be INSTALLED.
Check that VPP attached the SAs to the tunnel interface:
Sample output for the tunnel interface vti of the same tunnel:
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.