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

Cilium eBPF Host-Routing MTU Clamping and WireGuard Overlay Guardrail

Enforces deterministic MTU calculation and kernel-level MSS path discovery when Cilium native eBPF host-routing is coupled with WireGuard transparent encryption. Bypassing Linux netfilter through eBPF host-routing invalidates traditional iptables TCPMSS clamping, causing silent TCP blackholing when packets with the Don't Fragment (DF) bit exceed the effective overlay payload size. This guardrail mandates explicit MTU deduction for WireGuard headers, ensures ICMP 'Packet Too Big' generation, and eliminates asymmetric routing loops across inter-cluster and cross-subnet topologies.

Prohibited Anti-Pattern: Unclamped 1500 MTU with Native eBPF Host Routing and WireGuard Encryption Inducing Silent TCP Blackholes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Host-Routing MTU Clamping and WireGuard Overlay Guardrail - Enforces deterministic MTU calculation and kernel-level MSS path discovery when Cilium native eBPF host-routing is coupled with WireGuard transparent encryption. Bypassing Linux netfilter through eBPF host-routing invalidates traditional iptables TCPMSS clamping, causing silent TCP blackholing when packets with the Don't Fragment (DF) bit exceed the effective overlay payload size. This guardrail mandates explicit MTU deduction for WireGuard headers, ensures ICMP 'Packet Too Big' generation, and eliminates asymmetric routing loops across inter-cluster and cross-subnet topologies.
globs: **/cilium-values.yaml, **/cilium.yaml, **/helm/**/cilium/**/*.yaml, **/terraform/**/*.tf, **/manifests/cilium/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-host-routing-mtu-clamping-guardrail"
---

# Cilium eBPF Host-Routing MTU Clamping and WireGuard Overlay Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unclamped 1500 MTU with Native eBPF Host Routing and WireGuard Encryption Inducing Silent TCP Blackholes

## System Constraints
You are a Principal Infrastructure & Network Kernel Architect enforcing strict network invariant guardrails for Kubernetes clusters running Cilium CNI with eBPF host-routing and WireGuard encryption. Your mandate is to eliminate silent TCP dropouts, PMTU discovery failures, and asymmetric routing anomalies by guaranteeing mathematically exact MTU calculations and proper eBPF TC/XDP configuration.

## Strict Guidelines
- Engineers MUST ALWAYS explicitly deduct WireGuard encapsulation overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the underlying network interface MTU when configuring Cilium's 'mtu' parameter.
- Engineers MUST NOT rely on Cilium's automatic MTU discovery when nodes traverse heterogeneous network paths, hybrid cloud VPNs, or underlays with nested encapsulations (e.g., Geneve, VXLAN, AWS VPC 9001 MTU peering with 1500 MTU transit gateways).
- Configurations MUST explicitly evaluate 'bpf.hostRouting': if the kernel is < 5.10 or if dynamic Path MTU Discovery (PMTUD) ICMP Type 3 Code 4 packets fail to reach ingress endpoints due to asymmetric egress bypass, 'bpf.hostRouting' MUST be set to 'false' to route through standard Linux stack TC/netfilter, or eBPF MSS clamping MUST be explicitly bound to the native interface.
- Engineers MUST NEVER enable transparent encryption ('encryption.enabled: true', 'encryption.type: wireguard') alongside native host-routing ('bpf.hostRouting: true') without configuring explicit device targeting via 'devices' matching regex or network interface names.
- Code SHOULD enforce automated CI pre-flight validation on all Helm values to verify that 'tunnel: disabled' (direct routing) matches the node subnet topology and does not produce asymmetric return paths when traffic exits via host endpoints.

## Bad vs Good Implementations
### Cilium Helm Configuration: MTU Calculation and Host Routing with WireGuard

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: When 'bpf.hostRouting' is true, packets transition directly from the pod's TC hook to the physical net device, bypassing the netfilter iptables FORWARD chain where TCPMSS clamping normally lives. Without explicit MTU adjustment, WireGuard encapsulates full 1500-byte packets into 1560-byte frames, causing fragmentation drops upstream without ICMP PTB feedback.
```yaml
# Flawed Cilium Helm values producing silent TCP drops over WireGuard
cilium:
  routingMode: native
  autoDirectNodeRoutes: true
  bpf:
    hostRouting: true # Bypasses iptables tc MSS clamping entirely
  encryption:
    enabled: true
    type: wireguard
  # MTU is left unconfigured, defaulting to 1500 (or blind auto-detection)
  # Underlay MTU 1500 - 60 byte WireGuard header = 1440 actual PMTU.
  # Senders set DF=1 on 1500-byte packets, eBPF drops them, pod hangs on TLS handshake.
```

#### Production Standard (Correct)
> **Standard**: Explicitly hardens the MTU to 1440 (accounting for the 60-byte WireGuard IPv4 transport header on standard 1500 MTU interfaces), restricts network attachment via 'devices' to prevent unmanaged device leakage, and enables Cilium dynamic PMTU discovery to correctly signal ICMP fragmentation needs.
```yaml
# Hardened Cilium Helm values with exact MTU clamping and overlay safety
cilium:
  routingMode: native
  autoDirectNodeRoutes: true
  ipv4:
    enabled: true
  ipv6:
    enabled: false
  # Base interface MTU (1500) - WireGuard overhead (60 bytes) = 1440 MTU
  mtu: 1440
  devices: "eth0+"
  bpf:
    hostRouting: true
    masquerade: true
    tproxy: true
  encryption:
    enabled: true
    type: wireguard
    wireguard:
      # Dynamic PMTUD feedback loop protection
      persistentKeepalive: 25
  tunnel: disabled
  pmtuDiscovery:
    enabled: true
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Host-Routing MTU Clamping and WireGuard Overlay Guardrail

Cilium eBPF Host-Routing MTU Clamping and WireGuard Overlay Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic MTU calculation and kernel-level MSS path discovery when Cilium native eBPF host-routing is coupled with WireGuard transparent encryption. Bypassing Linux netfilter through eBPF host-routing invalidates traditional iptables TCPMSS clamping, causing silent TCP blackholing when packets with the Don't Fragment (DF) bit exceed the effective overlay payload size. This guardrail mandates explicit MTU deduction for WireGuard headers, ensures ICMP 'Packet Too Big' generation, and eliminates asymmetric routing loops across inter-cluster and cross-subnet topologies. 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: Unclamped 1500 MTU with Native eBPF Host Routing and WireGuard Encryption Inducing Silent TCP Blackholes 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 DriftUnclamped 1500 MTU with Native eBPF Host Routing and WireGuard Encryption Inducing Silent TCP BlackholesCritical
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 explicitly deduct WireGuard encapsulation overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the underlying network interface MTU when configuring Cilium's 'mtu' parameter.

Engineers MUST ALWAYS explicitly deduct WireGuard encapsulation overhead (minimum 60 bytes for IPv4, 80 bytes for IPv6) from the underlying network interface MTU when configuring Cilium's 'mtu' parameter.

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 Cilium's automatic MTU discovery when nodes traverse heterogeneous network paths, hybrid cloud VPNs, or underlays with nested encapsulations (e.g., Geneve, VXLAN, AWS VPC 9001 MTU peering with 1500 MTU transit gateways).

Engineers MUST NOT rely on Cilium's automatic MTU discovery when nodes traverse heterogeneous network paths, hybrid cloud VPNs, or underlays with nested encapsulations (e.g., Geneve, VXLAN, AWS VPC 9001 MTU peering with 1500 MTU transit gateways).

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

Configurations MUST explicitly evaluate 'bpf.hostRouting'

Configurations MUST explicitly evaluate 'bpf.hostRouting': if the kernel is < 5.10 or if dynamic Path MTU Discovery (PMTUD) ICMP Type 3 Code 4 packets fail to reach ingress endpoints due to asymmetric egress bypass, 'bpf.hostRouting' MUST be set to 'false' to route through standard Linux stack TC/netfilter, or eBPF MSS clamping MUST be explicitly bound to the native interface.

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

Engineers MUST NEVER enable transparent encryption ('encryption.enabled

Engineers MUST NEVER enable transparent encryption ('encryption.enabled: true', 'encryption.type: wireguard') alongside native host-routing ('bpf.hostRouting: true') without configuring explicit device targeting via 'devices' matching regex or network interface names.

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

Code SHOULD enforce automated CI pre-flight validation on all Helm values to verify that 'tunnel

Code SHOULD enforce automated CI pre-flight validation on all Helm values to verify that 'tunnel: disabled' (direct routing) matches the node subnet topology and does not produce asymmetric return paths when traffic exits via host endpoints.

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 MTU Clamping and WireGuard Overlay Guardrail critical for AI coding assistants?

Enforces deterministic MTU calculation and kernel-level MSS path discovery when Cilium native eBPF host-routing is coupled with WireGuard transparent encryption. Bypassing Linux netfilter through eBPF host-routing invalidates traditional iptables TCPMSS clamping, causing silent TCP blackholing when packets with the Don't Fragment (DF) bit exceed the effective overlay payload size. This guardrail mandates explicit MTU deduction for WireGuard headers, ensures ICMP 'Packet Too Big' generation, and eliminates asymmetric routing loops across inter-cluster and cross-subnet topologies. 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 (Unclamped 1500 MTU with Native eBPF Host Routing and WireGuard Encryption Inducing Silent TCP Blackholes) 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