I configured bandwidth throttling for HTTP and ftp FTP using following commands:

sudo /sbin/tc qdisc add dev eth0 root handle 1:0 htb default 1
sudo /sbin/tc class add dev eth0 parent 1:0 classid 1:1 htb rate 5kbps ceil 9kbps prio 0
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip sport 21 0xffff flowid 1:1

Then I checked with the wget command by downloading a file from the Internet. (Also checked with port 80 and 21). But the download speed is not changing, e.g. not limiting under the 9 Kbps.

What should I do? Do I have to configure delay also? If yes, how much?

2 Answers 2


The tc system only shapes outgoing packets on an interface (unless you are using ingress filtering, which you are not). As such, unless the computer on which you are running these commands is the server, no shaping will take place.

Also, as @Teun Vink said, port 21 is only for FTP control. To add to what he said about port 20, if you are using FTP in its passive mode (most likely), it is unlikely that you will be able to shape it based solely on tc filters as it will be using random high ports. In this case, you will likely need to use a combination of iptables to match the stream and set fwmarks, and tc rules to match.


Port 21 is used FTP Control. You should limit port 20 (FTP Data) if you want to limit FTP traffic, and create a similar rule for port 80 if you want to limit HTTP traffic.

  • Thanks for the reply. I checked with "sport" and "dport" as 20 and i try to download a file with "wget". But still the bandwidth is not shaping...any suggestions?
    – Veerendra
    Aug 15, 2015 at 17:08
  • 3
    Nope, I've never used tc before. You may have better luck on a stack exchange more focused on linux like unix.stackexchange.com or Super User.
    – Teun Vink
    Aug 15, 2015 at 17:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.