# Configuration

Configure packet inspecting, mirroring, and redirecting.

## Configuration

> [!WARNING]
>
> Enabling Junction will incur fees. Once enabled, Junction will be billed according to its runtime, regardless of actual usage. Billing will continue until Junction is disabled. Refer to the [Pricing & Fee Schedule](https://docs.soracom.io/en/pricing) for more information.

Before enabling Junction, ensure that you have completed the following:

- Create a [Virtual Private Gateway](https://docs.soracom.io/en/services/vpg).
- Create a [Soracom Air for Cellular Group](https://docs.soracom.io/en/services/groups/usage).
- Configure your group's [Virtual Private Gateway option](https://docs.soracom.io/en/services/air/vpg) to use your VPG.
- [Add Air for Cellular subscribers](https://docs.soracom.io/en/services/groups/usage) to the group.

If you want to enable Junction Redirection, you must also complete [Gate Peer Configuration](https://docs.soracom.io/en/services/gate/gate-peer-configuration).

Then, enable Junction for your VPG:

1. Sign in to the **[User Console](https://console.soracom.io/?coverage_type=g)**. From the **☰ Menu**, open the **VPG** screen.

2. From the list of VPGs, click the **name** of the VPG you want to configure to open its settings page.

3. Click the **Junction settings** tab.

4. Configure **Inspection**, **Mirroring**, or **Redirection** settings as necessary:

   - **SORACOM Junction: Inspection**

     ![Junction Inspection configuration](https://docs.soracom.io/_astro/vpg-junction-inspection.N_yld3go_ZzedYo.webp)

     1. Enable Inspection by switching the option to **ON**.

     2. Enter the configuration parameters:

        - **Service** - The cloud service where packet statistic information will be sent.
        - **Destination** or **Topic** - The cloud service endpoint.
        - **Credential set** - The credentials to use for this connection. For more information on creating credential sets see the [Credential Sets](https://docs.soracom.io/en/services/authentication/credential-sets) documentation.

     3. Click the **Save Inspection Settings** button.

   - **SORACOM Junction: Mirroring**

     ![Junction Mirroring configuration](https://docs.soracom.io/_astro/vpg-junction-mirroring.DkMhxEKL_Z1hokGA.webp)

     1. Click the **+ Add Mirroring Destination** button.
     2. Enter the **Mirroring destination IP address**, and set the **Status** to **ON**.
     3. Click the **Save** button.

   - **SORACOM Junction: Redirection**

     ![Junction Redirection configuration](https://docs.soracom.io/_astro/vpg-junction-redirection.KubdL0Um_2jbT4o.webp)

     1. Enable Redirection by switching the option to **ON**.
     2. Click the **Gateway IP address** dropdown box and select the IP address that corresponds to your Gate Peer.
     3. Click the **Save Redirection Settings** button.

Settings will take effect immediately.

## Advanced Configuration

Soracom Junction settings can also be configured programmatically using the Soracom API or Soracom CLI. In either case, Inspection, Mirroring, and Redirection configuration is specified in the following JSON formats:

### Inspection Configuration Format

```json
{
  "enabled": true,
  "report": {
    "credentialsId": "<CREDENTIAL-SET-ID>",
    "enabled": true,
    "destination": {
      "service": "aws-iot"|"kinesis"|"firehose"|"eventhubs"|"pubsub",
      "provider": "aws"|"azure"|"google",
      "resourceUrl": "<DESTINATION-ADDRESS>"
    }
  }
}
```

### Mirroring Configuration Format

```json
{
  "enabled": true,
  "protocol": "gre",
  "description": "<OPTIONAL-DESCRIPTION>",
  "ipAddress": "<DESTINATION-IP-ADDRESS>"
}
```

### Redirection Configuration Format

```json
{
  "enabled": true,
  "gateway": "<GATE-PEER-INNER-IP-ADDRESS>",
  "description": "<OPTIONAL-DESCRIPTION>"
}
```

### Soracom API

#### Inspection

To configure Inspection settings, use the **setInspectionConfiguration** API method:

**Global**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Inspection configuration }' \
  http://g.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/set_inspection
```

**Japan**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Inspection configuration }' \
  http://jp.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/set_inspection
```

You can remove Inspection settings with the **unsetInspectionConfiguration** method.

#### Mirroring

To add a mirroring destination, use the **createMirroringPeer** API method:

**Global**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Mirroring peer configuration }' \
  http://g.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/mirroring/peers
```

**Japan**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Mirroring peer configuration }' \
  http://jp.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/mirroring/peers
```

You can modify a mirroring peer with the **updateMirroringPeer** method, and delete a mirroring peer with the **deleteMirroringPeer** method.

#### Redirection

To configure Redirection settings, use the **setRedirectionConfiguration** API method:

**Global**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Redirection configuration }' \
  http://g.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/set_redirection
```

**Japan**

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -b '{ ... Redirection configuration }' \
  http://jp.api.soracom.io/v1/virtual_private_gateways/<VPG-ID>/junction/set_redirection
```

You can remove Redirection settings with the **unsetRedirectionConfiguration** method.

### Soracom CLI

#### Inspection

To configure Inspection settings, use the `set-inspection` command:

**Global**

```bash
soracom vpg set-inspection --vpg-id '<VPG-ID>' --body '{ ... Inspection configuration }' --coverage-type g
```

**Japan**

```bash
soracom vpg set-inspection --vpg-id '<VPG-ID>' --body '{ ... Inspection configuration }' --coverage-type jp
```

You can remove Inspection settings with the `unset-inspection` command.

#### Mirroring

To add a mirroring destination, use the `create-mirroring-peer` command:

**Global**

```bash
soracom vpg create-mirroring-peer --vpg-id '<VPG-ID>' --body '{ ... Mirroring peer configuration }' --coverage-type g
```

**Japan**

```bash
soracom vpg create-mirroring-peer --vpg-id '<VPG-ID>' --body '{ ... Mirroring peer configuration }' --coverage-type jp
```

You can modify a mirroring peer with the `update-mirroring-peer` command, and delete a mirroring peer with the `delete-mirroring-peer` command.

#### Redirection

To configure Redirection settings, use the `set-redirection` command:

**Global**

```bash
soracom vpg set-redirection --vpg-id '<VPG-ID>' --body '{ ... Redirection configuration }' --coverage-type g
```

**Japan**

```bash
soracom vpg set-redirection --vpg-id '<VPG-ID>' --body '{ ... Redirection configuration }' --coverage-type jp
```

You can remove Redirection settings with the `unset-redirection` command.
