Skip to main content
24 votes

Using tc to delay packets to only a single IP address

The chosen answer is incorrect/incomplete. I faced a similar issue, the chosen answer gave some help, but not enough. First, the following command is not really needed. tc qdisc del dev eth0 root ...
Telegrapher's user avatar
13 votes
Accepted

How to do traffic shaping (rate limiting) with TC per OpenVPN client

Here is a solution, how to do traffic shaping for data rate limiting of individual clients with tc (traffic control) using a script called by OpenVPN. The traffic control settings are handled in a ...
rda's user avatar
  • 1,987
9 votes

Network shaping using `tc netem` doesn't seem to work

I finally figured it out. After careful studying of this and this chapters I have much better understanding of how it is supposed to work and how tc processes packets. So basically, what I need to do,...
peetonn's user avatar
  • 261
7 votes
Accepted

How to check all active netem rules?

The command tc qdisc (or tc q) will show all active queueing disciplines, including any instances of netem. For example, after running the command tc qdisc add dev eth0 root netem delay 25ms, the ...
aousterh's user avatar
  • 138
7 votes
Accepted

Using tc to decrease bandwidth to a specific destination address

Yes, the tc is designed for this. TC works over any types of interfaces (physical and software). Most simple queue scheduler is the htb (Hierarchical Token Bucket). Typical simple configuration: htb ...
Anton Danilov's user avatar
6 votes
Accepted

Limit bandwidth of a physical interface, turn a 10G link into a 1G link

Use ethtool: ethtool -s $IFACE speed 1000 Note that generally many SFPs only support a single speed. Running ethtool $IFACE will show supported rates and modes. In addition, you can use tc to reduce ...
vidarlo's user avatar
  • 9,794
4 votes

Traffic shaping: tc filter catch all filter

The question is rather old, but just in case someone comes across a similar problem. Parameter all can be used for protocol instead of ip to also filter for other traffic like arp. tc filter add dev ...
the's user avatar
  • 141
4 votes
Accepted

OpenVPN Variables Passed via Script

when a user connects to OpenVPN the following learn-address script is called The $1, $2, and $3 are the arguments passed to the script, that are documented in the man page. --learn-address cmd ... ...
Zoredache's user avatar
  • 132k
4 votes

Inject Delay between Virtual Machines in a VLAN

Creating delays can be simulated by the traffic shaping algorithms supported by the Linux kernel. From the netem manual: # tc qdisc add dev eth0 root handle 1: prio # tc qdisc add dev eth0 parent 1:3 ...
HBruijn's user avatar
  • 81k
4 votes
Accepted

Attempting to shape traffic for both IPv4 and IPv6 results in a conflict

The filter priority isn't family specific. So, your commands to create filters should look like: /sbin/tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 1/0xF fw flowid 1:1 /sbin/tc filter ...
Anton Danilov's user avatar
4 votes

How to remove the ingress delay introduced using tc

I figured out the answer. Following are the sequence of commands to recover. tc qdisc del dev eth0 handle ffff: ingress modprobe -r ifb
Dinesh's user avatar
  • 171
4 votes

How to apply `fq_codel` to balance traffic in multiple VLAN connections?

fq_codel is not a shaper, but a qdisc that does fair queuing and aqm. tbf and htb are shapers, as is cake in bandwidth mode. Up until this very moment I thought fq_codel peeled off the vlan headers, ...
Dave Taht's user avatar
3 votes

Minimum bandwidth limit on Linux systems

Yes it is the right tool. In fact the traffic shaping is implemented on kernel level. tc is the userland interface tool to control it. It is part of the iproute2 package. http://lartc.org/ has good ...
rda's user avatar
  • 1,987
3 votes

How to limit speed for every device per MAC address in the gateway via Linux command "tc"?

Use this example: tc qdisc del dev eth1 root tc qdisc add dev eth1 root handle 1: htb default 10 tc class add dev eth1 parent 1: classid 1:10 htb rate 1mbit ceil 1mbit tc class add dev eth1 ...
norman alpuiz's user avatar
3 votes

How to add latency and bandwidth-limit interface using tc?

In your example, you are trying to add two root qdiscs on the egress. The second command fails because you already have a root qdisc, and only one is allowed. Instead, create the root qdisc, then a ...
aousterh's user avatar
  • 138
3 votes

tc netem possibly missing

To check if the netem module is indeed installed run: modinfo sch_netem You should see info about where it is installed and other details. If you get an error like "modinfo: ERROR: Module ...
Pierz's user avatar
  • 703
3 votes
Accepted

Traffic Control - is it possible to distinguish between www browsing and www bulk (iso download) traffic?

Your solution relies on web browser behaviour to set IP ToS field accordingly. This could be relied upon only in trusted environment. I can easily write mangle rules on my machine to flatten all ToS ...
Nikita Kipriyanov's user avatar
3 votes
Accepted

Reduce the network traffic priority in Linux

This could be done the way I describing below. First we should change the root discipline of interface (usually pfifo_fast) with the prio one: tc q a dev eno1 root handle 1: prio This command creates ...
red0ct's user avatar
  • 404
2 votes

Traffic shaping: tc filter attached to an HTB class?

It is possible. I believe tc(8) man is not comprehensive. Citing from man7.org/tc(8): tc filters If tc filters are attached to a class, they are consulted first for relevant instructions. ...
Dawer's user avatar
  • 121
2 votes

How to match port range using u32 filter

I made a script to do what @alvosu described for anyone interested. http://blog.roeften.com/2017/01/mask-calculator.html Currently it will include more ports on the right of the range. The fiddle ...
Roeften's user avatar
  • 136
2 votes

linux tc qdisc pie (aqm) configuration with limited bandwidth

PIE was added to the Linux kernel in version 3.14 (https://www.linux.com/news/linux-314-release-no-pi-new-pie-fights-bufferbloat), so you need a Linux version >= 3.14 in order to run PIE. In order to ...
aousterh's user avatar
  • 138
2 votes

RTNETLINK answers: File exists when using netem with tc

shorter solution: sudo tc qdisc replace dev eth0 root netem delay 100ms
Daniil Burmashev's user avatar
2 votes

Using tc to delay packets to only a single IP address

I haven't manage to delay traffic to one IP while keeping traffic normal to others IP normal with the method described in this thread. However, I manage to do it using the following commands. tc ...
Nicolas Henneaux's user avatar
2 votes

Using tc to delay packets to only a single IP address

Simple example from https://wiki.linuxfoundation.org/networking/netem that lets you delay packets to a given IP without affecting any other traffic, even during configuration: tc qdisc del dev eth0 ...
NeilenMarais's user avatar
2 votes

How to limit speed for every device per MAC address in the gateway via Linux command "tc"?

Here is an example based on https://amd.co.at/adminwiki/Linux_Trafficshaping: #!/bin/bash #Cleaning up tc qdisc del dev eth0 root handle 1: > /dev/null 2>&1 #Add the root handle, setting ...
Luca Gibelli's user avatar
  • 2,791
2 votes

LINUX: multiq leaf not replaceable with tc

Well, holistically it's solvable by changing default qdisc, since mq does initialize it's leave to the default qdisc. So ... sysctl -w net.core.default_qdisc=<your_qdisc> tc qdisc replace dev &...
cherusk's user avatar
  • 41
2 votes

Bandwidth limit for multiple network destinations with a default (slow) match with Linux TC

Finally got it working. These lines show what I'm doing: tc qdisc del dev vmn0 root tc qdisc add dev vmn0 root handle 1: htb default 11 r2q 83 tc class add dev vmn0 parent 1: classid 1:1 htb rate ...
vroman's user avatar
  • 76
2 votes
Accepted

How to change HTB rate of a classid?

Perhaps you could try something like this: sudo tc class change dev br0 parent 1:1 classid 1:10 htb rate 1kbit ceil 5kbit burst 16b
Heaveysam's user avatar
2 votes

Why doesn't this "tc filter" rule classify the traffic at intended?

Whats Your kernel version? I'm trying to configure similar thing, and becoming to have strong feeling that kernel debian 4.15.0-23-generic is broken. Problem is not with HTB itself, but with ...
Tomáš Šimek's user avatar
2 votes
Accepted

Limit packet rate, open connections, and IP addresses

I don't have an answer for nr. 2 (see below). For 1. and 3. you can use the limit module: Control the network packet number rate: iptables -A OUTPUT -m limit --limit 10/s -j ACCEPT Control the ...
Luca Gibelli's user avatar
  • 2,791

Only top scored, non community-wiki answers of a minimum length are eligible