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.

UPF NAT

UPG allows the creation of UPF NAT as an additional NAT type upf, alongside basic and cgnat. While UPF NAT and CG-NAT shares the same dataplane, it does not involve the SMC in selecting the NAT Pool directly. Instead, the NAT Pool is selected based on the Forwarding Policy selected by the SMC.

This document details the behavior, configuration, and current limitations of UPF NAT.

Configuration

To utilize UPF NAT, you must deploy UPG using the UPGDeployment. NAT is configured on the Core Cluster using additional Custom Resources: UPGNatPool and UPGForwardingPolicy - those objects are created based on spec.instances.{NAME}.nat.pools and spec.instances.{NAME}.forwardingPolicies. Although NAT Pools can be added dynamically, removing them is not currently recommended. Forwarding Policies, however, can be added and removed without impacting the dataplane.

UPG Configuration

Below is an overview of the UPG configuration using the UPGDeployment object:

yaml

This example configures standard UPG settings while also incorporating the NAT Pool and Forwarding Policies configurations detailed in the subsequent sections.

NAT Configuration

The global NAT configuration is defined within the spec.nat field of the UPGDeployment:

yaml

These settings cannot be edited at runtime; any modifications will trigger a restart of the UPG instances.

The spec.nat.enabled flag activates NAT, while the spec.nat.type field specifies the NAT type (which must be set to upf).

The spec.nat.maxNatPort and spec.nat.minNatPort parameters define the port range (minimum and maximum) used to create a NAT binding, which is a tuple consisting of an IP address and port range for translating User Equipment traffic.

Per-protocol session idle timeouts, measured in seconds, are configured under the spec.nat.timeouts section:

  • icmp: The ICMP idle timeout (default is 60).
  • tcpEstablished: The TCP established idle timeout (default is 1800).
  • tcpTransitory: The TCP transitory idle timeout (default is 240).
  • udp: The UDP idle timeout (default is 300).

NAT Pool Configuration

The spec.instances.{NAME}.nat.pools section in the UPGDeployment configures the NAT Pools utilized by connected User Equipment. Each NAT Pool is associated with an NWI via the interface name.

Multiple NAT Pools may share a single interface on the SGi side. Every NAT Pool must define a complete networking section, encompassing IP addresses, MTU, and FPPNetwork configurations. These settings must be identical across all NAT Pools sharing the interface. This requirement ensures that if one NAT Pool is deleted, the remaining pools retain their interface configuration without disruption.

mssClamping and ueFlowsLimit are mutable on any pool, and shared pools also allow the address range (start and end) to change. These updates apply at runtime without recreating the pool. Changing mssClamping or ueFlowsLimit keeps sessions intact, while removing addresses from a shared pool's range terminates the sessions that use them. Any other change requires deleting the pool and deploying a replacement with the updated parameters. Deleting a NAT Pool releases every UE session bound to it. The UPF terminates each affected session and reports it to the Control Plane. Sessions bound to other NAT Pools are not affected.

Each NAT Pool has an optional mode that controls how external ports are allocated (the default is cgnat):

  • cgnat: reserves a port block of blocksize ports per UE. All flows from a UE keep the same external address and port block.
  • shared: dynamically allocates ports per flow from the pool's whole port range (minNatPort to maxNatPort). All flows from a UE keep the same external address, but the external port can differ between flows.

The mode is fixed once the NAT Pool is created.

shared pools also support ueFlowsLimit, which caps the number of concurrent TCP/UDP NAT flows per UE. The default is 64, and 0 removes the limit. It has no effect on cgnat pools.

Set mssClamping on a pool to clamp the TCP MSS of its NAT traffic to the given value. 0 disables clamping. It applies to both cgnat and shared pools.

Below is a sample NAT Pool configuration:

yaml

Forwarding Policies Configuration

Forwarding Policies are defined within the spec.instances.{NAME}.forwardingPolicies section of the UPGDeployment. These policies can be dynamically added, removed, or modified at runtime. The configuration is applied to the UPG immediately without requiring a restart, taking effect on live traffic.

Each Forwarding Policy name must be unique within a single UPGDeployment instance (e.g., policy-au and policy-de in the example below). Additionally, all NAT Pools referenced under spec.instances.{NAME}.forwardingPolicies.{POLICY-NAME}.natPools must be explicitly defined in the spec.instances.{NAME}.nat.pools section.

yaml

UPG distributes new sessions across the policy's NAT Pools in proportion to each pool's capacity (the number of external addresses in its range). In cgnat mode, UPG skips a pool once its port blocks are exhausted. A shared-mode pool draws ports per flow, so UPG never considers it exhausted.

Verification

To verify that the UPGDeployment is successfully installed and ready, execute the following command on the Management Cluster:

bash

Sample output:

bash

You can also verify the status of the VPPDeployment resource, which is generated by the UPGDeployment Custom Resource in the Core Cluster (using the namespace defined in spec.targetNamespace, such as gmcp-pgw):

bash

Output:

text

NAT Pool and Forwarding Policy configuration

On the Core Cluster, you can access the UPG pod via exec to run the following diagnostic commands.

NAT Pools

To inspect the NAT Pool configuration:

bash

Sample output:

text

NAT Pool statistics are exposed through the following UPG metrics:

  • vpp_nat_pool_info{name="pool-au",network_instance="sgi"} 1
  • vpp_nat_pool_utilization{name="pool-au",network_instance="sgi"} 0
  • vpp_nat_pool_block_size{name="pool-au",network_instance="sgi"} 64
  • vpp_nat_pool_capacity{name="pool-au",network_instance="sgi"} 1008
  • vpp_nat_pool_bytes_total{direction="i2o",name="pool-au",thread="0"} 30660
  • vpp_nat_pool_bytes_total{direction="o2i",name="pool-au",thread="0"} 30576
  • vpp_nat_pool_flow_count{name="pool-au",thread="0",type="icmp"} 0
  • vpp_nat_pool_flow_count{name="pool-au",thread="0",type="tcpudp"} 0

Forwarding Policies

To view the Forwarding Policies, run the following command within the UPG pod:

bash

Sample output:

text

Core Cluster configuration objects

Additionally, you can monitor the status of Kubernetes API objects directly on the Core Cluster. Events related to the creation or deletion of the UPGNatPool and UPGForwardingPolicy Custom Resources are published there. Examples include:

  • Successful NAT Pool Creation:

    text
  • Successful Forwarding Policy Creation:

    text
  • Failed Forwarding Policy Modification (Missing NAT Pool):

    text

In case of an error, events will be published at regular intervals. If no events are present for a specific object, it indicates that the configuration was either applied successfully and the event expired or that it was never applied.

UPG NAT traffic

To verify that traffic is passing through the NAT, you can list the active NAT flows. Execute the following commands on the UPG pod:

  • ICMP flows

    bash

    Sample output:

    text
  • TCP/UDP flows:

    bash

    Sample output:

    text