# Configure dual-stack networking

This guide covers two dual-stack configurations:

- [IPv4-first dual-stack]() (recommended) — ScyllaDB uses IPv4 internally, services accessible via both protocols
- [IPv6-first dual-stack]() — ScyllaDB uses IPv6 internally, services accessible via both protocols

For IPv6-only (single-stack) deployments, see [Configure IPv6-only](https://operator.docs.scylladb.com/v1.22/deploy-scylladb/set-up-networking/ipv6/configure-single-stack.md). For configuration field details, see the [IPv6 configuration reference](https://operator.docs.scylladb.com/v1.22/reference/ipv6-configuration.md).

## Configure dual-stack networking with IPv4

**What you’ll achieve**: Deploy a ScyllaDB cluster that uses IPv4 for ScyllaDB communication and provides services accessible via both IPv4 and IPv6.

**Before you begin**:

- You have a Kubernetes cluster with dual-stack networking enabled
- You have ScyllaDB Operator installed
- You have `kubectl` configured

**After completion**: Your ScyllaDB cluster will use IPv4 for inter-node communication while services are accessible via both IPv4 and IPv6.

#### NOTE
This is the recommended configuration for production IPv6 deployments.

### Step 1: Apply the configuration

Apply the dual-stack configuration:

```shell
kubectl create namespace scylla
kubectl apply -f=https://raw.githubusercontent.com/scylladb/scylla-operator/v1.22/examples/ipv6/scylla-cluster-dual-stack.yaml
```

### Step 2: Wait for the cluster to be ready

Monitor pod creation:

```bash
kubectl get pods -n scylla -l scylla-operator.scylladb.com/pod-type=scylladb-node -w
```

Wait until all pods show `Running` status.

### Step 3: Verify dual-stack configuration

Check that services have both IP families:

```bash
kubectl get svc -n scylla -o custom-columns=NAME:.metadata.name,IP-FAMILIES:.spec.ipFamilies,POLICY:.spec.ipFamilyPolicy
```

Expected output shows `[IPv4 IPv6]` for IP families:

```default
NAME                            IP-FAMILIES        POLICY
scylla-dual-stack-client        [IPv4 IPv6]        PreferDualStack
scylla-dual-stack-us-east-1a-0  [IPv4 IPv6]        PreferDualStack
```

### Step 4: Verify cluster health

Check that all nodes are up:

```bash
kubectl exec -it scylla-dual-stack-example-rack-0 -n scylla -c scylla -- nodetool status
```

**Expected output:**

```default
Datacenter: dual-stack-datacenter
===================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address           Load      Tokens  Owns  Host ID                              Rack
UN  fd00:10:244:1::7f 501.79 KB 256     ?     4583fff5-2aa6-4041-9be8-c74bcabaff8c dual-stack-rack-a
UN  fd00:10:244:2::6d 494.49 KB 256     ?     b1f889b4-80e7-4685-a3c5-1b81797c2ce4 dual-stack-rack-a
UN  fd00:10:244:3::6c 494.96 KB 256     ?     7a4bb6da-415e-4fc3-a6ca-0369c0e76bf0 dual-stack-rack-a
```

All nodes should show `UN` (Up/Normal) status.

### Next steps

- [Migrate existing clusters to IPv6](https://operator.docs.scylladb.com/v1.22/deploy-scylladb/set-up-networking/ipv6/migration.md)
- [Troubleshoot IPv6 issues](https://operator.docs.scylladb.com/v1.22/deploy-scylladb/set-up-networking/ipv6/troubleshooting.md)

## Configure dual-stack networking with IPv6

**What you’ll achieve**: Deploy a ScyllaDB cluster that uses IPv6 for ScyllaDB communication and provides services accessible via both IPv6 and IPv4.

**Before you begin**:

- You have a Kubernetes cluster with dual-stack networking enabled
- You have ScyllaDB Operator installed
- You have `kubectl` configured

**After completion**: Your ScyllaDB cluster will use IPv6 for inter-node communication while services are accessible via both IPv6 and IPv4.

#### NOTE
This configuration is production-ready. For IPv4-first dual-stack, see [Configure dual-stack with IPv4]().

### Step 1: Create the configuration

Create a file `scylla-ipv6-first.yaml`:

```yaml
apiVersion: scylla.scylladb.com/v1
kind: ScyllaCluster
metadata:
  name: scylla-ipv6-first
  namespace: scylla
spec:
  version: 6.2.2
  agentVersion: 3.3.3
  datacenter:
    name: datacenter1
    racks:
      - name: rack1
        members: 3
        storage:
          capacity: 100Gi
          storageClassName: scylladb-local-xfs
        resources:
          limits:
            cpu: 4
            memory: 16Gi
          requests:
            cpu: 4
            memory: 16Gi
  
  network:
    ipFamilyPolicy: PreferDualStack
    ipFamilies:
      - IPv6  # ScyllaDB uses IPv6
      - IPv4  # Services also support IPv4
    dnsPolicy: ClusterFirst
  
  exposeOptions:
    nodeService:
      type: Headless
    broadcastOptions:
      nodes:
        type: PodIP
        podIP:
          source: Status
      clients:
        type: ServiceClusterIP
```

### Step 2: Apply the configuration

```bash
kubectl create namespace scylla
kubectl apply -f scylla-ipv6-first.yaml
```

### Step 3: Wait for the cluster to be ready

Monitor pod creation:

```bash
kubectl get pods -n scylla -l scylla-operator.scylladb.com/pod-type=scylladb-node -w
```

Wait until all pods show `Running` status.

### Step 4: Verify dual-stack configuration

Check that services have both IP families:

```bash
kubectl get svc -n scylla -o custom-columns=NAME:.metadata.name,IP-FAMILIES:.spec.ipFamilies,POLICY:.spec.ipFamilyPolicy
```

Expected output shows `[IPv6 IPv4]` for IP families:

```default
NAME                              IP-FAMILIES        POLICY
scylla-ipv6-first-client          [IPv6 IPv4]        PreferDualStack
scylla-ipv6-first-datacenter1-... [IPv6 IPv4]        PreferDualStack
```

### Step 5: Verify cluster uses IPv6

Check that ScyllaDB is using IPv6 addresses:

```bash
NAMESPACE=scylla
CLUSTER_NAME=scylla-ipv6-first

pods=$(kubectl -n "${NAMESPACE}" get pods -l scylla/cluster="${CLUSTER_NAME}" -l scylla-operator.scylladb.com/pod-type=scylladb-node -o name)

for pod in ${pods}; do
  kubectl -n "${NAMESPACE}" exec "${pod}" -c scylla -- nodetool status
done
```

Expected output shows IPv6 addresses (with colons):

```default
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address              Load      Tokens  Owns  Host ID                              Rack
UN  fd00:10:244:1::7f    501.79 KB 256     ?     4583fff5-2aa6-4041-9be8-c74bcabaff8c rack1
UN  fd00:10:244:2::6d    494.49 KB 256     ?     b1f889b4-80e7-4685-a3c5-1b81797c2ce4 rack1
UN  fd00:10:244:3::6c    494.96 KB 256     ?     7a4bb6da-415e-4fc3-a6ca-0369c0e76bf0 rack1
```

### Next steps

- [Migrate existing clusters to IPv6](https://operator.docs.scylladb.com/v1.22/deploy-scylladb/set-up-networking/ipv6/migration.md)
- [Troubleshoot IPv6 issues](https://operator.docs.scylladb.com/v1.22/deploy-scylladb/set-up-networking/ipv6/troubleshooting.md)
