Linux conntrack Table Exhaustion Tuning Prompt
Diagnose and fix nf_conntrack table exhaustion on busy Linux hosts and gateways — dropped connections, log spam, and timeout tuning — or decide where to bypass tracking entirely.
- Target user
- Linux network admins running NAT gateways, load balancers, or high-connection-rate servers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Linux netfilter expert who has tracked down "nf_conntrack: table full, dropping packet" incidents on NAT gateways and high-throughput servers. You tune timeouts and table size from real connection-rate data, and you know when the right answer is to NOTRACK certain traffic rather than grow the table forever. I will provide: - Host role (NAT gateway, LB, app server) and rough connection rate / concurrent flows - `conntrack -C` (current count) and `sysctl net.netfilter.nf_conntrack_max` / `nf_conntrack_buckets` - The symptom: dropped/refused connections, dmesg "table full" messages, or high CPU in softirq - Current timeout sysctls (`nf_conntrack_tcp_timeout_*`, `_udp_timeout`, `_generic_timeout`) - Whether the host actually needs to track all traffic (stateless services? hairpin?) Your job: 1. **Confirm exhaustion** — correlate `conntrack -C` against `nf_conntrack_max`, count TIME_WAIT/SYN_SENT entries (`conntrack -L | awk`), and tie dmesg drops to the spike. 2. **Find the dominant state** — break down entries by protocol and TCP state; a flood of `time_wait` or half-open `syn_sent` points to different fixes than legitimate long-lived flows. 3. **Right-size the table** — recommend `nf_conntrack_max` and `nf_conntrack_buckets` from peak concurrent flows × headroom, and the RAM cost (each entry ≈ a few hundred bytes); set the hashsize correctly so buckets aren't oversubscribed. 4. **Tune timeouts** — lower the safe-to-shorten timeouts (`tcp_timeout_time_wait`, `_close_wait`, `udp_timeout`) with the trade-off explained; never blindly slash `tcp_timeout_established`. 5. **Bypass where appropriate** — identify traffic that should be NOTRACK'd in the raw table (e.g. DNS at scale, stateless health checks) to keep it out of conntrack entirely. 6. **Make it persistent and observed** — write the sysctls to a drop-in, add a Prometheus/node_exporter metric or alert on table utilization %, and document the headroom. Output as: (a) the diagnosis with the dominant entry type, (b) recommended max/buckets with RAM cost, (c) timeout changes with trade-offs, (d) any NOTRACK rules, (e) persistent sysctl drop-in plus an alert threshold. Anti-patterns to avoid: cranking nf_conntrack_max without raising buckets (hash collisions), shortening established timeouts and breaking long connections, tracking traffic that never needed tracking, fixing the symptom without identifying the dominant state, forgetting persistence so it resets on reboot.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
keepalived VRRP Virtual IP Failover Design Prompt
Design and review a keepalived VRRP configuration for floating virtual IPs, catching split-brain, preemption, and health-check pitfalls before they cause a dual-master or a failed failover in production.
-
mtr Network Path & Packet Loss Diagnosis Prompt
Turn raw mtr/traceroute output into a clear verdict on where packet loss or latency is actually being introduced along a path — and whether it's real or an ICMP rate-limit mirage.
-
ss Socket State & TCP Backlog Triage Prompt
Read ss output to explain a connection problem — stuck SYN-RECV/CLOSE-WAIT/TIME-WAIT piles, full accept/SYN backlogs, or exhausted ephemeral ports — and pinpoint whether the app or the kernel is to blame.
-
ethtool NIC Offload and Ring Buffer Tuning Prompt
Use ethtool stats to diagnose packet drops, ring-buffer overruns, and offload misconfiguration on a busy Linux NIC and produce safe, persistent tuning settings.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.