> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/upg/latest/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/upg/latest/operation-guides/nwi.md).

# Configure NWIs

User Plane Gateway (UPG) uses Network Instances (NWIs). NWI is a logical representation of a network interface that connects UPG to various networks (like Access, Control, and Data Networks). The NWIs are declared using the `spec` configuration from the UPGDeployment CR on the Management Cluster, which is in turn translated into [UPGConfig](https://docs.cennso.com/components/upg/latest/concepts/upgconfig.md) Custom Resource (CR) in the Core Cluster. UPG then creates NWIs based on UPGConfig CR.

You can configure the UPGDeployment CR to create NWIs in two ways:

- Set the **spec.type** parameter to `pgw` or `tdf` to use preconfigured values for these use cases (PGW or TDF).
- Configure the **spec.nwis** section to manually specify NWI names and types.

## Use case examples

You can configure the UPGDeployment CR to create NWIs for these use cases:

- Packet Gateway (PGW)
- Traffic Detection Function (TDF)
- GTP Proxy

### PGW

You can create NWIs for the PGW use case by setting the **spec.type** value to `pgw`. In this case, these default NWIs are created:

- `epc`
- `cp`
- `sgi`

You can also configure these NWIs by manually setting the name and type of NWI in the **spec.nwis** section:

```yaml
spec:
  nwis:
    access:
      name: epc     # The Access Network NWI name. Use `epc` for PGW mode or `access` for TDF mode.
      type: gtpu    # The Access Network NWI type. Use `gtpu` for PGW mode or `tdf` for TDF mode.
    control:
      name: cp      # The Control Network NWI name. Use `cp` for all modes.
      type: gtpu    # The Control Network NWI type. Always use `gtpu` for all modes.
    data:
      name: sgi     # The Data Network NWI name. Use `sgi` for PGW mode. Not used in TDF mode.
      type: ip      # The Data Network NWI type. Use `ip` for PGW mode. Not used in TDF mode.
```

This configuration results in the following UPGConfig CR:

```yaml
apiVersion: upg-manager.cennso.com/v1alpha1
kind: UPGConfig
metadata:
  labels:
    fpp-manager.cennso.com/created-for: upg-operator
    fpp-manager.cennso.com/plumbing-instance: upg-fpp-inst01
  name: upg-fpp-inst01
  namespace: basic-pgw
spec:
  nwis:
  - ipv4TableID: 0
    ipv6TableID: 0
    name: cp
  - ipv4TableID: 100
    ipv6TableID: 100
    name: epc
  - ipv4TableID: 200
    ipv6TableID: 200
    name: sgi
```

### TDF

To create NWIs for the TDF use case, set the **spec.type** parameter to `tdf`. For the TDF use case, these default NWIs are created:

- `access`
- `cp`
- multiple `sgi`s (one for each destination NAT pool)

>**CAUTION:** Do not use the **spec.nwis** section to configure NWIs manually.

Data Networks are configured one per NAT pool, based on `spec.instances.{name}.nat.pools`. If `spec.nat.enabled: true` and `spec.nat.type: cgnat` are configured, the UPGDeployment CR also adds an `sgi` NWI.

See the NWI configuration example for TDF-U:

```yaml
spec:
  nwis:
    access:
      name: access
      type: tdf

  nat:
    enabled: true
    type: cgnat
  instances:
    inst01:
      networking:
        (...)
      nat:
        pools:
          pool-de:
            networking:
              interface: de1
          (...)
          pool-at:
            networking:
              interface: at1
          (...)
```

This configuration results in the following UPGConfig CR:

```yaml
apiVersion: upg-manager.cennso.com/v1alpha1
kind: UPGConfig
metadata:
  labels:
    fpp-manager.cennso.com/created-for: upg-operator
    fpp-manager.cennso.com/plumbing-instance: upg-fpp-inst01
  name: upg-fpp-inst01
  namespace: basic-pgw
spec:
  nwis:
  - ipv4TableID: 0
    ipv6TableID: 0
    name: cp
  - ipv4TableID: 100
    ipv6TableID: 100
    name: access
  - ipv4TableID: 200
    ipv6TableID: 200
    name: at1
  - ipv4TableID: 300
    ipv6TableID: 300
    name: de1
```

### GTP Proxy

To create NWIs for the GTP Proxy use case, specify the **spec.nwis** configuration. See the NWI configuration example for the GTP Proxy use case, where Access and Data Networks use only GTP endpoints:

```yaml
spec:
  nwis:
    access:
      name: access
      type: gtpu
    data:
      name: core
      type: gtpu
```

This configuration results in the following UPGConfig CR:

```yaml
apiVersion: upg-manager.cennso.com/v1alpha1
kind: UPGConfig
metadata:
  labels:
    fpp-manager.cennso.com/created-for: upg-operator
    fpp-manager.cennso.com/plumbing-instance: upg-fpp-inst01
  name: upg-fpp-inst01
  namespace: basic-pgw
spec:
  pfcp:
    heartbeat:
      timeout: 10
      retries: 3
  nwis:
  - ipv4TableID: 0
    ipv6TableID: 0
    name: cp
  - ipv4TableID: 100
    ipv6TableID: 100
    name: access
  - ipv4TableID: 200
    ipv6TableID: 200
    name: core
```

## Verification

After applying the configuration, you can verify the NWI setup on your Core Cluster using the VPP CLI by running the following command:

```bash
vppctl sh upf nwi
```

This is the output example that shows the NWI setup:

```
epc default: ip4-table-id 100, ip6-table-id 100, tx-ip4-table-id 100, tx-ip6-table-id 100, ipfix-policy none, ipfix-collector-ip 0.0.0.0
sgi default: ip4-table-id 200, ip6-table-id 200, tx-ip4-table-id 200, tx-ip6-table-id 200, ipfix-policy none, ipfix-collector-ip 0.0.0.0
cp default: ip4-table-id 0, ip6-table-id 0, tx-ip4-table-id 0, tx-ip6-table-id 0, ipfix-policy none, ipfix-collector-ip 0.0.0.0
```
