LinuxCommandLibrary

tc

Linux traffic control and shaping

TLDR

Add constant delay

$ sudo tc qdisc add dev eth0 root netem delay 100ms
copy
Add variable delay
$ sudo tc qdisc add dev eth0 root netem delay 100ms 20ms
copy
Add packet loss
$ sudo tc qdisc add dev eth0 root netem loss 5%
copy
Limit bandwidth
$ sudo tc qdisc add dev eth0 root tbf rate 10mbit burst 32kbit latency 400ms
copy
Show active policies
$ tc qdisc show dev eth0
copy
Delete all rules
$ sudo tc qdisc delete dev eth0
copy
Change rule
$ sudo tc qdisc change dev eth0 root netem delay 50ms
copy

SYNOPSIS

tc [OPTIONS] OBJECT COMMAND

DESCRIPTION

tc (traffic control) configures kernel packet scheduling, shaping, and filtering. It can simulate network conditions like latency, packet loss, and bandwidth limits for testing or quality of service management.

PARAMETERS

qdisc

Queuing discipline - manage packet queuing
add
Add a new traffic control policy
delete
Remove traffic control policy
change
Modify existing policy
show
Display current policies
netem
Network emulation (delay, loss, corruption)
tbf
Token bucket filter (bandwidth limiting)
delay ms
Add latency to packets
loss percent
Drop percentage of packets
rate bandwidth
Maximum bandwidth rate

CAVEATS

Affects outgoing traffic only. For bidirectional control, configure on both ends. Changes are immediate and can disrupt network connectivity. Not persistent across reboots.

HISTORY

tc is part of iproute2, the Linux networking toolkit, providing advanced traffic shaping and network emulation.

SEE ALSO

ip(8), ethtool(8)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard