Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions calico-cloud/networking/configuring/allowed-source-prefixes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description: Allow pods to send traffic with a source IP address outside their own using the allowedSourcePrefixes annotation.
---

# Allow pods to use additional source IP prefixes

## Big picture

Allow pods to send egress traffic using source IP addresses outside their own pod IP, by specifying allowed source prefixes.

## Value

By default, Calico blocks egress traffic from a pod when the source IP does not match the pod's IP. This prevents IP spoofing. Some workloads, such as a pod that acts as a transparent proxy and preserves the original client source IP, need to send traffic with a different source address. The `allowedSourcePrefixes` annotation relaxes the spoofing check for the prefixes you list on a specific pod.

## Concepts

### Source IP spoofing protection

Calico programs dataplane rules that drop egress packets from a pod when the source IP does not match the pod's own IP. The `allowedSourcePrefixes` annotation relaxes this restriction for specific IP prefixes on a per-pod basis. It works with both the iptables/nftables and the eBPF dataplanes.

Check failure on line 19 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'dataplanes'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'dataplanes'?", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 284}}}, "severity": "ERROR"}

Check failure on line 19 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [CalicoStyle.Substitutions] Use 'data planes' instead of 'dataplanes'. Raw Output: {"message": "[CalicoStyle.Substitutions] Use 'data planes' instead of 'dataplanes'.", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 284}}}, "severity": "ERROR"}

Check failure on line 19 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'dataplane'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'dataplane'?", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 17}}}, "severity": "ERROR"}

Check failure on line 19 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'. Raw Output: {"message": "[CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'.", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 17}}}, "severity": "ERROR"}

### FelixConfiguration prerequisite

Allowing non-pod source IPs is security-sensitive, so Felix rejects the annotation by default. You must opt in by setting `workloadSourceSpoofing` to `Any` in the FelixConfiguration resource. Until you do, a pod that requests source prefixes is not programmed into the dataplane.

Check failure on line 23 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'. Raw Output: {"message": "[CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'.", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 23, "column": 270}}}, "severity": "ERROR"}

Check failure on line 23 in calico-cloud/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'dataplane'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'dataplane'?", "location": {"path": "calico-cloud/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 23, "column": 270}}}, "severity": "ERROR"}

## Before you begin...

Comment thread
tomastigera marked this conversation as resolved.
- Your cluster must be using Calico CNI to use this feature. See [Configuring the Calico CNI Plugins](../../reference/component-resources/configuration.mdx).
- Enable `workloadSourceSpoofing` in the FelixConfiguration resource:

```yaml
apiVersion: projectcalico.org/v3
kind: FelixConfiguration
metadata:
name: default
spec:
workloadSourceSpoofing: Any
```

:::caution

Setting `workloadSourceSpoofing` to `Any` lets any pod that carries the annotation send traffic with arbitrary source IPs. Use admission control to restrict which pods can set the annotation.

:::

## How to

Annotate the pod with `cni.projectcalico.org/allowedSourcePrefixes` set to a JSON list of CIDRs. For example:

```yaml
cni.projectcalico.org/allowedSourcePrefixes: '["192.168.10.0/24"]'
```

The annotation must be present when the pod is created; adding it later has no effect.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description: Allow pods to send traffic with a source IP address outside their own using the allowedSourcePrefixes annotation.
---

# Allow pods to use additional source IP prefixes

## Big picture

Allow pods to send egress traffic using source IP addresses outside their own pod IP, by specifying allowed source prefixes.

## Value

By default, Calico blocks egress traffic from a pod when the source IP does not match the pod's IP. This prevents IP spoofing. Some workloads, such as a pod that acts as a transparent proxy and preserves the original client source IP, need to send traffic with a different source address. The `allowedSourcePrefixes` annotation relaxes the spoofing check for the prefixes you list on a specific pod.

## Concepts

### Source IP spoofing protection

Calico programs dataplane rules that drop egress packets from a pod when the source IP does not match the pod's own IP. The `allowedSourcePrefixes` annotation relaxes this restriction for specific IP prefixes on a per-pod basis. It works with both the iptables/nftables and the eBPF dataplanes.

Check failure on line 19 in calico-enterprise/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'dataplanes'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'dataplanes'?", "location": {"path": "calico-enterprise/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 284}}}, "severity": "ERROR"}

Check failure on line 19 in calico-enterprise/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'. Raw Output: {"message": "[CalicoStyle.Substitutions] Use 'data plane' instead of 'dataplane'.", "location": {"path": "calico-enterprise/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 17}}}, "severity": "ERROR"}

Check failure on line 19 in calico-enterprise/networking/configuring/allowed-source-prefixes.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'dataplane'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'dataplane'?", "location": {"path": "calico-enterprise/networking/configuring/allowed-source-prefixes.mdx", "range": {"start": {"line": 19, "column": 17}}}, "severity": "ERROR"}

### FelixConfiguration prerequisite

Allowing non-pod source IPs is security-sensitive, so Felix rejects the annotation by default. You must opt in by setting `workloadSourceSpoofing` to `Any` in the FelixConfiguration resource. Until you do, a pod that requests source prefixes is not programmed into the dataplane.

## Before you begin...

- Your cluster must be using Calico CNI to use this feature. See [Configuring the Calico CNI Plugins](../../reference/component-resources/configuration.mdx).
- Enable `workloadSourceSpoofing` in the FelixConfiguration resource:

```yaml
apiVersion: projectcalico.org/v3
kind: FelixConfiguration
metadata:
name: default
spec:
workloadSourceSpoofing: Any
```

:::caution

Setting `workloadSourceSpoofing` to `Any` lets any pod that carries the annotation send traffic with arbitrary source IPs. Use admission control to restrict which pods can set the annotation.

:::

## How to

Annotate the pod with `cni.projectcalico.org/allowedSourcePrefixes` set to a JSON list of CIDRs. For example:

```yaml
cni.projectcalico.org/allowedSourcePrefixes: '["192.168.10.0/24"]'
```

The annotation must be present when the pod is created; adding it later has no effect.
53 changes: 53 additions & 0 deletions calico/networking/configuring/allowed-source-prefixes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description: Allow pods to send traffic with a source IP address outside their own using the allowedSourcePrefixes annotation.
---

# Allow pods to use additional source IP prefixes

## Big picture

Allow pods to send egress traffic using source IP addresses outside their own pod IP, by specifying allowed source prefixes.

## Value

By default, Calico blocks egress traffic from a pod when the source IP does not match the pod's IP. This prevents IP spoofing. Some workloads, such as a pod that acts as a transparent proxy and preserves the original client source IP, need to send traffic with a different source address. The `allowedSourcePrefixes` annotation relaxes the spoofing check for the prefixes you list on a specific pod.

## Concepts

### Source IP spoofing protection

Calico programs dataplane rules that drop egress packets from a pod when the source IP does not match the pod's own IP. The `allowedSourcePrefixes` annotation relaxes this restriction for specific IP prefixes on a per-pod basis. It works with both the iptables/nftables and the eBPF dataplanes.

### FelixConfiguration prerequisite

Allowing non-pod source IPs is security-sensitive, so Felix rejects the annotation by default. You must opt in by setting `workloadSourceSpoofing` to `Any` in the FelixConfiguration resource. Until you do, a pod that requests source prefixes is not programmed into the dataplane.

## Before you begin...

Comment thread
tomastigera marked this conversation as resolved.
- Your cluster must be using Calico CNI to use this feature. See [Configuring the Calico CNI Plugins](../../reference/configure-cni-plugins.mdx).
- Enable `workloadSourceSpoofing` in the FelixConfiguration resource:

```yaml
apiVersion: projectcalico.org/v3
kind: FelixConfiguration
metadata:
name: default
spec:
workloadSourceSpoofing: Any
```

:::caution

Setting `workloadSourceSpoofing` to `Any` lets any pod that carries the annotation send traffic with arbitrary source IPs. Use admission control to restrict which pods can set the annotation.

:::

## How to

Annotate the pod with `cni.projectcalico.org/allowedSourcePrefixes` set to a JSON list of CIDRs. For example:

```yaml
cni.projectcalico.org/allowedSourcePrefixes: '["192.168.10.0/24"]'
```

The annotation must be present when the pod is created; adding it later has no effect.
1 change: 1 addition & 0 deletions sidebars-calico-cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ module.exports = {
'networking/configuring/secure-bgp',
'networking/configuring/workloads-outside-cluster',
'networking/configuring/pod-mac-address',
'networking/configuring/allowed-source-prefixes',
'networking/configuring/node-local-dns-cache',
'networking/configuring/qos-controls',
'networking/configuring/add-maglev-load-balancing',
Expand Down
1 change: 1 addition & 0 deletions sidebars-calico-enterprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ module.exports = {
'networking/configuring/secure-bgp',
'networking/configuring/workloads-outside-cluster',
'networking/configuring/pod-mac-address',
'networking/configuring/allowed-source-prefixes',
'networking/configuring/node-local-dns-cache',
'networking/configuring/qos-controls',
'networking/configuring/add-maglev-load-balancing',
Expand Down
1 change: 1 addition & 0 deletions sidebars-calico.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ module.exports = {
'networking/configuring/use-ipvs',
'networking/configuring/sidecar-acceleration',
'networking/configuring/pod-mac-address',
'networking/configuring/allowed-source-prefixes',
'networking/configuring/node-local-dns-cache',
'networking/configuring/qos-controls',
'networking/configuring/add-maglev-load-balancing',
Expand Down
Loading