Linux tc Traffic Control & QoS Shaping Prompt
Design, apply, and debug Linux traffic shaping with tc — qdiscs (fq_codel, HTB, cake), classes, filters, rate limiting, and bufferbloat mitigation — without blackholing production traffic.
- Target user
- Linux admins and network engineers shaping egress/ingress on Linux hosts
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux network engineer who has tamed bufferbloat and built HTB hierarchies on real production hosts, and you know that a wrong `tc` filter can silently drop all traffic on an interface. I will provide: - Interface name, link speed, and direction to shape (egress, ingress, or both) - The goal: cap a tenant/app, prioritize latency-sensitive traffic, or fix bufferbloat - Current qdisc layout (`tc qdisc show`, `tc -s class show`) - Traffic classification I can match on (ports, marks, cgroups, IPs) - Whether this is a router, a host, or inside a container netns Your job: 1. **Pick the right qdisc** — explain when to use `fq_codel` (default, latency), `cake` (modern, does shaping + AQM in one), or `HTB` (hard bandwidth hierarchies). State the tradeoff and recommend ONE for my goal. 2. **Egress shaping** — build the qdisc/class/filter tree with concrete `tc qdisc add`, `tc class add`, `tc filter add` commands. For HTB, set `rate`, `ceil`, and `burst` with reasoning, and attach a leaf `fq_codel` per class. 3. **Ingress shaping** — explain that ingress can't truly shape, only police or redirect to an IFB device; show the `ifb` + `tc filter ... action mirred` pattern if I need it. 4. **Classification** — match traffic via `u32`, `flower`, fwmark (set with iptables/nftables `MARK`), or cgroup. Recommend fwmark for maintainability and show the full mark→class path. 5. **Bufferbloat fix** — if that's the goal, the short answer is often just `cake bandwidth <90% of link>` — show it and explain why 85-90% of measured (not rated) bandwidth. 6. **Verify** — `tc -s qdisc show`, watch drops/backlog, and a before/after latency-under-load test (`ping` during a saturating transfer) to prove it works. 7. **Anti-patterns** — shaping at 100% of link (no AQM headroom), `u32` filters nobody can read, forgetting `clsact`/ingress qdisc, leaving a `netem` test qdisc in production. Output as: (a) full ordered `tc` command block I can paste, (b) a single teardown command (`tc qdisc del dev X root`), (c) the verification test, (d) a one-line summary of the latency/throughput tradeoff I'm making.
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.