> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/3.15/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/smc/3.15/config/networking.md).

# Networking configuration

Session Management Controller (SMC) configuration includes basic networking settings. It is split into two major parts:
- Definition of the network interfaces and their IP addresses
- Mapping of those IP addresses to logical functions

## Network init container

SMC chart uses an init container to configure the pod networking. The SMC chart generates network configuration based
on `networking` section values.

If SMC cannot start and errors out after the init container, the SMC network configuration may be broken.
To check why it is happening, init container logs can be seen:

```bash
kubectl logs -n {SMC_NAMESPACE} {SMC_POD_NAME} -c network-init
```

## Network interfaces and IPs

SMC pod uses Kubernetes networking be default. However, you can add additional interfaces.
To use networking based on the Fast Path Provider (FPP) component, you must create a Network Attachment Definition (NAD) outside of the SMC chart, and reference it in annotations. See the example:

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx-fpp@grx"
```

NAD `grx-fpp` is used to create VPP's TAP interface, and the interface name is `grx`.
To configure the IP, use the following example:

```yaml
networking:
  interfaces:
    grx:
      vrf: epc
      endpoints:
        grx-0:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
            - to: 192.168.4.65
```

The example above configures the network interface `grx` and adds a single IP address to it. The IP is
named `grx-0` and that name can later be used to bind a GTP endpoint to that IP.

A `vrf` must be used for endpoints used to carry GTP or PFCP traffic between SMC and User Plane Gateway (UPG). A Linux VRF-Lite instance is used for every named `vrf`.

It is possible to create multiple IPs on an network interface. This example shows multiple IPs assigned to an
interface used for GTP traffic:

```yaml
networking:
  interfaces:
    grx-0:
      vrf: epc
      endpoints:
        grx-0:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
            - to: 192.168.4.65
    grx-1:
      vrf: epc
      endpoints:
        grx-1:
          ipv4:
            addr: "192.168.5.69/28"
```

### Additional interfaces for RADIUS and/or Diameter

> [!CAUTION]
> Additional RADIUS and Diameter interfaces can not use VRFs. IPs and routes added to those intefaces use the same routing domain as the normal pod networking. Be careful when selecting network ranges and IP address for RADIUS and Diameter to avoid leaking traffic the pod network and those additional interfaces.

> [!TIP]
> For VRF isolation of AAA traffic at the socket level, use the `netdev` transport option to bind the Diameter or RADIUS socket to a specific network device. See [Transport socket options](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md#transport-socket-options) for details.

RADIUS and Diameter can either use the pod networking or addition FPP-based interfaces. See the sample with additional interfaces for Rf and Gy traffic:

```
    rf-tposs0:
      endpoints:
        rf:
          ipv4:
            addr: 172.29.11.121/28
    gy0:
      endpoints:
        ro:
          ipv4:
            addr: 10.102.86.196/28
    oss-ctrl1:
      endpoints:
        radius:
          ipv4:
            addr: 172.22.14.2/24
```

In the resulting configuration, only the destination IPs control which traffic is routed
through which interface.

## Binding endpoints to functions

Once an IP endpoint is created, you can bind GTP and PFCP control traffic to it using the **networking.services** section.

### GTP networks

A GTP service creates a new named GTP instance. The **services.{SERVICE_NAME}.endpoint** parameter must reference an endpoint defined in **networking.interfaces**, formatted as `{IF_NAME}.{ENDPOINT_NAME}`. Set **services.{SERVICE_NAME}.type** to `grx`, **services.{SERVICE_NAME}.direction** to either `access` (towards the RAN) or `core` (towards the Internet), and **services.{SERVICE_NAME}.networkInstance** to the network instance name used by UPG for this network.

The full configuration of a single GTP instance with a single network interface and one IP using a NAD looks as follows:

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx-fpp@grx"

networking:
  interfaces:
    grx:
      vrf: epc
      endpoints:
        grx-endp:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
              - to: 192.168.4.65
  services:
    grx:
      endpoint: grx.grx-endp
      type: grx
      networkInstance: epc
      direction: access
```

See the configuration example of multiple GTP interfaces:

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx1-fpp@grx1,grx2-fpp@grx2"

networking:
  interfaces:
    grx1:
      vrf: epc
      endpoints:
        grx-1-endp:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
              - to: 192.168.4.65
    grx2:
      vrf: epc
      endpoints:
        grx-2-endp:
          ipv4:
            addr: "192.168.5.68/28"
            routes:
              - to: 192.168.5.65
  services:
    grx-1:
      endpoint: grx1.grx-1-endp
      type: grx
      networkInstance: epc
      direction: access
    grx-2:
      endpoint: grx2.grx-2-endp
      type: grx
      networkInstance: epc
      direction: access
```

Interfaces can have overlapping or even identical IP networks when different VRFs are used:

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx1-fpp@grx1,grx2-fpp@grx2"

networking:
  interfaces:
    grx1:
      vrf: epc-1
      endpoints:
        grx-1-endp:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
              - to: 192.168.4.65
    grx2:
      vrf: epc-2
      endpoints:
        grx-2-endp:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
              - to: 192.168.4.65
  services:
    grx-1:
      endpoint: grx1.grx-1-endp
      type: grx
      networkInstance: epc-1
      direction: access
    grx-2:
      endpoint: grx2.grx-2-endp
      type: grx
      networkInstance: epc-2
      direction: access
```

See the configuration example of a single GTP interface with multiple IPs:

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx-fpp@grx"

networking:
  interfaces:
    grx:
      vrf: epc
      endpoints:
        grx-1-endp:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
              - to: 192.168.4.65
        grx-2-endp:
          ipv4:
            addr: "192.168.5.68/28"
            routes:
              - to: 192.168.5.65
  services:
    grx-1:
      endpoint: grx.grx-1-endp
      type: grx
      networkInstance: epc
      direction: access
    grx-2:
      endpoint: grx.grx-2-endp
      type: grx
      networkInstance: epc
      direction: access
```

### Sx network service

The Sx network is used for PFCP communication and to connect with UPGs.
The overlay networking must be configured using pod NADs.

```yaml
annotations:
  "k8s.v1.cni.cncf.io/networks": "sx-fpp@sxb"
```

The Sx network configuration uses FPP-based networking in a form of Network Attachment Definition `sx-fpp` created
outside of the SMC chart. The interface name inside the SMC pod is `sxb`. It uses the VPP's TAP interface driver,
which provides fast packet processing inside VPP, and exposes a kernel-based interface inside the pod.

See the example of a control network with UPG connectivity configuration:

```yaml
networking:
  interfaces:
    sx2:
      vrf: cp
      endpoints:
        sx:
          ipv4:
            addr: "172.21.15.204/28"
  services:
    sx:
      endpoint: sx2.sx
      type: sx
      networkInstance: cp
upg:
  instances:
    prox01:
      networking:
        sx:
          ipv4:
            addr: 172.21.15.205/28
      ip_pool: sgi
```

This example configures the IP with netmask to `sxb`, which is an interface name from the pod's
network annotation. SMC connects to UPG using the SX interface and IP address defined in
**upg.instances.{UPG_NAME}.networking.sx.ipv4.addr**.

## Manual configuration

SMC chart allows you to configure interfaces in a form of a bash script. To switch to the manual configuration,
set **networking.manual** to `true`, **initScript.enabled** to `true`, and provide the configuration script in the **initScript.script** value.

The **networking.interfaces** and **networking.services** parameters for GTP and Sx interfaces are required even in manual mode
to create the SMC configuration. GTP and Sx interfaces and their IPs must match definitions in **networking.interfaces**.

See the example:

```yaml
networking:
  manual: true
initScript:
  enabled: true
  script: |
    ip address add 192.168.4.68/28 dev grx
    ip route add 192.168.4.65 dev grx table 100
    ip rule add from 192.168.4.68/28 table 100
networking:
  interfaces:
    grx0:
      endpoints:
        grx:
          ipv4:
            addr: "192.168.4.68/28"
  services:
    grx:
      endpoint: grx0.grx
      type: grx
      networkInstance: epc
      direction: access
```
