tc is the Linux command for traffic control, the iproute2 utility that configures how the kernel queues, schedules, shapes and drops network packets on each interface. In Linux networking, it is the main administrative interface to the kernel packet scheduler, used to limit bandwidth, prioritize latency-sensitive traffic, emulate poor networks and attach programmable filters.
Where tools such as nftables decide whether a packet is allowed, tc decides when and in what order packets leave an interface. It belongs to the same iproute2 package as the ip command and follows a similar object-based syntax built around three concepts: queuing disciplines, classes and filters.
How tc controls the kernel packet scheduler
Every network interface in Linux has a queuing discipline, or qdisc, attached to its egress path. When the kernel sends a packet, it enqueues it into this qdisc, and the qdisc decides when to dequeue it toward the driver. tc replaces or tunes that qdisc and, for classful qdiscs, builds a tree of classes that divides bandwidth among traffic groups.
Objects are identified by handles in the major:minor form, such as 1: for a root qdisc and 1:10 for one of its classes. Filters attached to a qdisc or class inspect packets and assign them to a class, using matches on addresses, ports, firewall marks or eBPF programs.
The following table summarizes the building blocks that a tc configuration combines.
| Object | Function | Example command |
|---|---|---|
| Qdisc | Queues and schedules packets on an interface | tc qdisc add dev eth0 root fq_codel |
| Class | Subdivides a classful qdisc with its own rate or priority | tc class add dev eth0 parent 1: classid 1:10 htb rate 50mbit |
| Filter | Classifies packets into classes | tc filter add dev eth0 parent 1: protocol ip u32 match ip dport 22 0xffff flowid 1:10 |
| Action | Modifies, drops, mirrors or redirects matched packets | action mirred egress redirect dev ifb0 |
| Handle | Identifies an object in the tree | 1:, 1:10, ffff: |
An important limitation is that shaping applies mainly to egress traffic. The ingress side offers only a simple ingress or clsact hook for policing and filtering. To shape incoming traffic, administrators redirect it to an Intermediate Functional Block (IFB) device and apply a qdisc on that device’s egress path.
Common queuing disciplines
The choice of qdisc determines whether tc limits rate, enforces priority or reduces latency. Classless qdiscs treat all packets on an interface in one structure, while classful qdiscs host a hierarchy of classes with separate rules.
| Qdisc | Type | Typical purpose |
|---|---|---|
| fq_codel | Classless | Default on many distributions, fights bufferbloat with fair queuing and CoDel |
| HTB | Classful | Hierarchical bandwidth guarantees and ceilings per class |
| TBF | Classless | Simple rate limit with a token bucket |
| netem | Classless | Emulates delay, jitter, loss, duplication and reordering |
| fq | Classless | Per-flow pacing, often paired with BBR congestion control |
| CAKE | Classless | All-in-one shaper for home and edge links |
| prio | Classful | Strict priority bands without rate limits |
| mqprio and taprio | Classful | Hardware queue mapping and time-aware scheduling |
HTB (Hierarchical Token Bucket) is the usual choice for multi-class bandwidth sharing. Each class receives a guaranteed rate and may borrow up to a ceil value when parent capacity is idle. Leaf classes generally carry their own qdisc, often fq_codel to keep queues short.
tc compared with related Linux networking tools
tc is often confused with firewall tools because both inspect packets, but its job is scheduling rather than access control. The table places it among neighboring utilities.
| Tool | Main role | Relation to tc |
|---|---|---|
| tc | Queuing, shaping, policing, emulation | Configures the packet scheduler |
| ip command | Addresses, links, routes | Same iproute2 package, similar syntax |
| nftables and iptables | Filtering and NAT | Can set firewall marks that tc filters match |
| ethtool | NIC driver and hardware settings | Controls ring buffers and offloads that affect tc results |
| tcpdump | Packet capture | Used to verify the effect of tc rules |
A common pattern combines tools: nftables marks packets by application or user, and a tc fw filter places marked packets into HTB classes. Modern setups increasingly attach eBPF programs through the clsact hook, which gives programmable classification at high speed and is used by container networking projects such as Cilium.
Typical tc tasks and commands
Most practical tc work falls into a handful of recurring tasks, from inspecting statistics to emulating a slow mobile link. The decision table below links each goal to a suitable approach.
| Goal | Recommended approach | Reason |
|---|---|---|
| Cap upload bandwidth | TBF or HTB root with a single class | Simple and predictable rate limit |
| Guarantee bandwidth per service | HTB tree with filters by port or mark | Rate and ceiling per class |
| Reduce latency under load | fq_codel or CAKE on the bottleneck | Keeps queues short |
| Test an application on a bad network | netem with delay and loss | Reproducible impairment |
| Shape downloads | IFB device with HTB or CAKE | Ingress cannot be shaped directly |
To inspect the current state, tc -s qdisc show dev eth0 prints counters for sent bytes, drops, overlimits and backlog, which reveal whether a shaper is actually limiting traffic. A netem test such as tc qdisc add dev eth0 root netem delay 100ms 20ms loss 1% adds an average of 100 ms delay with 20 ms jitter and 1 percent loss, and tc qdisc del dev eth0 root restores the default.
Pitfalls when using tc
tc rules are not persistent across reboots and are lost when an interface is recreated. They must be reapplied by a script, a systemd unit or a network manager integration such as systemd-networkd, which supports several qdiscs in its configuration files.
- Shaping must happen at the real bottleneck; limiting a 1 Gbit interface does nothing if the upstream modem queue fills first, so set the rate slightly below the true link speed
- Offloads such as GSO and TSO create large aggregated packets that distort token bucket accounting at low rates
- Applying netem on a remote server’s only interface can lock out the SSH session that configured it
- Unclassified traffic in HTB falls to the
defaultclass, and an omitted default can leave traffic unshaped
The short version
Think of a network connection as a single checkout lane in a busy shop. tc is the store manager who organizes the line. The manager decides who goes first and how many customers pass per minute.
With it, a Linux machine can keep a video call smooth during a large download. It can stop one service from taking all the bandwidth. It can even slow itself down on purpose to test software on a weak connection. The key idea is simple: tc controls the order and pace of outgoing traffic.
Where it makes a difference
A small company runs its backups, voice phones and office traffic through a Linux router on a 100 Mbit/s upload link. Every evening the nightly backup saturates the link and phone calls become choppy, because packets wait behind large backup transfers in a long queue.
The administrator installs an HTB tree with a root rate of 95 Mbit/s, just under the real link speed. A voice class receives a guaranteed 10 Mbit/s and top priority, office traffic gets 50 Mbit/s with a ceiling of 95, and backups get 20 Mbit/s that can borrow unused capacity. nftables marks packets by port, tc fw filters sort them, and each leaf runs fq_codel. Afterward, tc -s class show confirms the backup class absorbing all drops, and call quality stays clear during backups that still finish before morning.