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

# Networking

SMC configuration includes basic networking settings. It is possible to configure the IP addresses for the following networks:

* Access network (`grx`)
* Control network (`sx`)
* Interface used to connect to AAA-related instances (`oss`)
* RADIUS interface (`radius`)
* Ro interface (`ro`) - specialized settings to connect to Online Charging System
* Gx interface (`gx`) - specialized settings to connect to policy exchange from PCRF

## 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-ns} {smc-pod-name} -c network-init
```

## Access network

The access network is used for GTP-C or TDF-C. To utilize FPP-based networking, Network Attachment Definition (NAD)
should be created outside of the SMC chart, and referenced in annotations, together with disabling `vxlanController`:

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

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

```yaml
networking:
  grx:
    interface: grx
    ipv4:
      addr: "192.168.4.68/28"
      routes:
        - to: 192.168.4.65
```

It is possible to configure multiple IPs for the access network interface, for example:

```yaml
networking:
  grx:
    - interface: grx
      ipv4:
        addr: "192.168.4.68/28"
        routes:
          - to: 192.168.4.65
    - interface: grx
      ipv4:
        addr: "192.168.4.69/28"
```

When using multiple IPs from the same network, routes added to the same interface should not overlap - do not declare
the same routes twice.

There can be multiple access network interfaces, together with multiple NADs usage example:

```yaml
vxlanController:
  enabled: false
annotations:
  "k8s.v1.cni.cncf.io/networks": "grx1-fpp@grx1,grx2-fpp@grx2"
networking:
  grx:
    - interface: grx1
      ipv4:
        addr: "192.168.4.68/28"
        routes:
          - to: 192.168.4.65
    - interface: grx2
      ipv4:
        addr: "192.168.5.68/28"
        routes:
          - to: 192.168.5.65
```

## Control network

The Control network is used for PFCP communication and to connect with UPG. The overlay networking used should be
configured via pod annotations, together with disabling `vxlanController`:

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

The control network configuration uses FPP based network 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.

Example control network with UPG connectivity configuration:

```yaml
networking:
  sx:
    interface: sxb
    ipv4:
      addr: "172.20.0.10/24"
upg:
  instances:
    inst01:
      networking:
        sx:
          ipv4:
            addr: 172.20.0.20/24
      ip_pool: pool01
```

This will configure the `networking.sx.ipv4.addr` IP with netmask to `sxb` (which is an interface name from the pod's
network annotation). SMC will try to reach UPG using the SX interface and IP address defined in
`upg.instances.{upg-name}.networking.sx.ipv4.addr`.

## Manual configuration

SMC chart exposes the possibility to configure interfaces in a form of a bash script. To do this manual configuration,
set `networking.manual` to `true`, `initScript.enabled` to `true` and provide config script in `initScript.script` value.

Control network configuration (SX) is required even when manual network configuration.

Example:

```yaml
networking:
  manual: true
  sx:
    interface: sxb
    ipv4:
      addr: "172.20.0.10/24"
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
```
