32

I would like to know the easiest way to limit outgoing bandwidth for an interface. I want to cap the outgoing port speed so that file transfers between my servers don't fail during busy hours.

What's the easiest solution? I know I could use iptables but I'm looking for a simple installation/configuration.

37

ethtool

You can change the aggregate speed of the NIC port using ethtool.

$ sudo ethtool -s eth0 speed 10

This will set the port to 10MB, for example.

wondershaper

You can also use the tool wondershaper to do it as well. NOTE: Speed should be in kilobits per second.

$ sudo wondershaper eth1 downspeed upspeed

For example:

$ sudo wondershaper eth0 10000 280

trickle

A 3rd option is Trickle. Trickle can be used per program by users or as a daemon that throttles the NIC completely.

User mode - trickle man page

$ sudo trickle -d 20 -u 20 wget http://www.google.com/bigfile

Will throttle 20K/s for both up and down traffic for just this wget, everything else will not be limited.

Daemon mode - trickled man page

In daemon mode, trickled can limit a group of programs to a fixed limit of bandwidth. To start the daemon, run the trickled command:

$ sudo trickled -d 20 -u 20

pyshaper

A 4th option is pyshaper. It's a unique option among the choices in that it includes GUI and it dynamically monitors and sets the bandwidth over time. You can check out the pyshaper man page for more details.

                                            pyshaper gui

References

  • Limiting bandwidth usage of the trouble applications via cgroups would probably also be worthwhile if their kernel supports it. – Bratchley Jul 22 '13 at 1:36
  • wondershaper isn't working I don't know why (even` wondershaper eth0 1000 1000` has no internet bandwidth same as ` sudo trickled -d 20 -u 20`.) I need to limit One network interface. bandwidth not only specific applications. how can in do that? – Arash Jun 29 '17 at 16:37
  • trickle did not work for me, but wondershaper did the trick! – peschü Jul 12 '17 at 20:31
1

Wondershaper was last edited in 2002 but it still works on Fedora 21 today. But note, there are only a couple of options available as arguments and you cannot specify the upload/download speed on the command line as specified here- at least, not in Download version 1.1a, released 16th of April 2002. You have to edit the file, and it's a shell script. Not hard for those who know a little shell.

Usage is:

wondershaper (this one will set your bandwidth according to the values in the file)

wondershaper status
wondershaper stop

You can use it while the link is up live, which is nice.

1

Another option is 'iproute2' which appears to be a mature and widely available traffic routing/shaping tool. I found it as an RPM (probably many other packages too, I didn't look). As of this writing, the most recent version was 4.4.0, built on 25 Jan 2016.

Looking over the configuration syntax, it appears to be relatively simple (though not as simple as ifconfig or route.)

  • 6
    Your answer doesn’t address how one actually would use iproute2 to limit outgoing bandwidth. Can you elaborate please? – Michael Sep 29 '16 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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