34

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.

Braiam
  • 35,991
Gabe
  • 341
  • HTB works great. Very flexible rate limiting. http://sourceforge.net/projects/htbinit/ –  Oct 01 '14 at 14:08

3 Answers3

41

ethtool

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

$ sudo ethtool -s eth0 speed 10

NOTE: This will set the port to 10MB, for example, you cannot set an arbitrary speed using this method!

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

slm
  • 369,824
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.

Mike S
  • 2,502
  • 2
  • 18
  • 29
0

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.)

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