This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-wireguard-mtu-clamping-invariant

Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant

Mandates explicit encapsulation headroom deduction, eBPF TCP MSS clamping, and interface MTU parity in Cilium deployments running eBPF host routing with transparent WireGuard encryption. This invariant eliminates silent PMTU blackholes, packet drop storms during TLS handshakes, and unrecoverable throughput degradation caused by eBPF bypass of netfilter MSS clamping.

Prohibited Anti-Pattern: Default 1500 MTU with Transparent WireGuard and eBPF Host Routing Bypassing Netfilter Clamping

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant - Mandates explicit encapsulation headroom deduction, eBPF TCP MSS clamping, and interface MTU parity in Cilium deployments running eBPF host routing with transparent WireGuard encryption. This invariant eliminates silent PMTU blackholes, packet drop storms during TLS handshakes, and unrecoverable throughput degradation caused by eBPF bypass of netfilter MSS clamping.
globs: **/values*.yaml, **/cilium*.yaml, **/charts/cilium/**/*.yaml, **/helm/cilium/**/*.yaml, infra/**/cilium*.tf
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-wireguard-mtu-clamping-invariant"
---

# Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Default 1500 MTU with Transparent WireGuard and eBPF Host Routing Bypassing Netfilter Clamping

## System Constraints
You are a Principal Infrastructure & Network Architect enforcing strict MTU, MSS clamping, and overlay headroom invariants in Cilium CNI. When Cilium operates with eBPF host-routing (`bpf.hostRouting=true`) and transparent WireGuard encryption, packets bypass netfilter iptables chains where standard `TCPMSS --clamp-mss-to-pmtu` hooks operate. If MTU is not explicitly configured to account for the WireGuard encapsulation overhead (at least 60 bytes for IPv4 and 80 bytes for IPv6), 1500-byte TCP frames will exceed the physical interface MTU and cause silent packet drops, broken TLS negotiations, and severe TCP retransmission cascades. You MUST mandate explicit headroom accounting and deterministic MTU configuration across all Helm values, CNI manifests, and node bootstrap configurations.

## Strict Guidelines
- Engineers MUST ALWAYS calculate and explicitly specify `mtu` in Cilium Helm values by subtracting WireGuard overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the minimum physical underlying fabric interface MTU (e.g., MTU 1440 or 1420 for an underlying 1500 MTU network).
- Engineers MUST NOT rely on default Linux iptables/netfilter MSS clamping rules (`iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS`) when `bpf.hostRouting=true` is enabled, as eBPF TC bypasses the netfilter stack entirely.
- Code SHOULD verify that `bpf.masquerade=true` and explicit device bindings (`devices: ["eth+", "en+"]`) are defined alongside WireGuard encryption to guarantee consistent eBPF fib-lookup routing paths.
- Services MUST ensure cross-node Pod-to-Pod and Pod-to-External egress traffic automatically negotiates a maximum TCP MSS of `Cilium_MTU - 40` (IPv4) or `Cilium_MTU - 60` (IPv6).
- Components NEVER deploy transparent WireGuard encryption with implicit MTU auto-detection enabled (`mtu: 0` or omitted) in heterogeneous cloud VPC fabrics where underlying MTUs differ between node pools.

## Bad vs Good Implementations
### Cilium Helm Configuration - MTU Clamping with WireGuard and Host Routing

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting the MTU configuration causes Cilium to infer an MTU of 1500 from the node's eth0 device. WireGuard encapsulation adds 60 bytes of overhead to inner Pod frames. Because eBPF host routing routes packets directly from the container veth to the physical device bypassing the host netfilter stack, iptables TCPMSS rules never execute. Packets with payload > 1440 bytes result in 1560-byte outer IP frames that cloud network hypervisors silently drop, blackholing TLS handshakes.
```yaml
# CRITICAL FAILURE: MTU is omitted (defaults to 1500 on 1500-MTU NICs)
# With WireGuard and bpf.hostRouting enabled, packets bypass netfilter,
# acquire 60-byte WireGuard overhead (total 1560B), and get dropped silently.
routingMode: native
ipv4NativeRoutingCIDR: 10.244.0.0/16
enryption:
  enabled: true
  type: wireguard
bpf:
  hostRouting: true
  masquerade: true
# mtu: <omitted>
```

#### Production Standard (Correct)
> **Standard**: By explicitly setting `mtu: 1440`, Cilium configures all Pod veth interfaces and internal eBPF routing logic to enforce a maximum transmission unit of 1440 bytes. eBPF handles TCP MSS negotiation directly during SYN/SYN-ACK packet processing, clamping the inner TCP MSS to 1400 bytes (1440 - 40 bytes IP/TCP header). When WireGuard encapsulates the frame, the final outer packet does not exceed the physical 1500-byte wire limit, entirely preventing fragmentation and drops.
```yaml
# CORRECT: Explicitly clamped MTU accounting for WireGuard overhead
# Physical fabric MTU: 1500
# WireGuard overhead: 60 bytes (IPv4) / 80 bytes (IPv6)
# podMTU = 1500 - 60 = 1440 (or 1420 to accommodate dual-stack/Geneve)
routingMode: native
ipv4NativeRoutingCIDR: 10.244.0.0/16
autoDirectNodeRoutes: true
mtu: 1440
enryption:
  enabled: true
  type: wireguard
  nodeEncryption: false
bpf:
  hostRouting: true
  masquerade: true
  tproxy: true
devices:
  - eth+
  - en+
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant

Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant defines an industrial-grade behavioral standard for devops engineering. Mandates explicit encapsulation headroom deduction, eBPF TCP MSS clamping, and interface MTU parity in Cilium deployments running eBPF host routing with transparent WireGuard encryption. This invariant eliminates silent PMTU blackholes, packet drop storms during TLS handshakes, and unrecoverable throughput degradation caused by eBPF bypass of netfilter MSS clamping. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Default 1500 MTU with Transparent WireGuard and eBPF Host Routing Bypassing Netfilter Clamping Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftDefault 1500 MTU with Transparent WireGuard and eBPF Host Routing Bypassing Netfilter ClampingCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS calculate and explicitly specify `mtu` in Cilium Helm values by subtracting WireGuard overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the minimum physical underlying fabric interface MTU (e.g., MTU 1440 or 1420 for an underlying 1500 MTU network).

Engineers MUST ALWAYS calculate and explicitly specify `mtu` in Cilium Helm values by subtracting WireGuard overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the minimum physical underlying fabric interface MTU (e.g., MTU 1440 or 1420 for an underlying 1500 MTU network).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT rely on default Linux iptables/netfilter MSS clamping rules (`iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS`) when `bpf.hostRouting=true` is enabled, as eBPF TC bypasses the netfilter stack entirely.

Engineers MUST NOT rely on default Linux iptables/netfilter MSS clamping rules (`iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS`) when `bpf.hostRouting=true` is enabled, as eBPF TC bypasses the netfilter stack entirely.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Code SHOULD verify that `bpf.masquerade=true` and explicit device bindings (`devices

Code SHOULD verify that `bpf.masquerade=true` and explicit device bindings (`devices: ["eth+", "en+"]`) are defined alongside WireGuard encryption to guarantee consistent eBPF fib-lookup routing paths.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST ensure cross-node Pod-to-Pod and Pod-to-External egress traffic automatically negotiates a maximum TCP MSS of `Cilium_MTU - 40` (IPv4) or `Cilium_MTU - 60` (IPv6).

Services MUST ensure cross-node Pod-to-Pod and Pod-to-External egress traffic automatically negotiates a maximum TCP MSS of `Cilium_MTU - 40` (IPv4) or `Cilium_MTU - 60` (IPv6).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER deploy transparent WireGuard encryption with implicit MTU auto-detection enabled (`mtu

Components NEVER deploy transparent WireGuard encryption with implicit MTU auto-detection enabled (`mtu: 0` or omitted) in heterogeneous cloud VPC fabrics where underlying MTUs differ between node pools.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Cilium eBPF Host Routing WireGuard MTU Clamping & Encapsulation Invariant critical for AI coding assistants?

Mandates explicit encapsulation headroom deduction, eBPF TCP MSS clamping, and interface MTU parity in Cilium deployments running eBPF host routing with transparent WireGuard encryption. This invariant eliminates silent PMTU blackholes, packet drop storms during TLS handshakes, and unrecoverable throughput degradation caused by eBPF bypass of netfilter MSS clamping. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Default 1500 MTU with Transparent WireGuard and eBPF Host Routing Bypassing Netfilter Clamping) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Cilium