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.

1

3 Answers 3

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

5
  • Limiting bandwidth usage of the trouble applications via cgroups would probably also be worthwhile if their kernel supports it.
    – Bratchley
    Jul 22, 2013 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, 2017 at 16:37
  • trickle did not work for me, but wondershaper did the trick!
    – peschü
    Jul 12, 2017 at 20:31
  • 1
    This answer should clarify that you cannot use ethtool to limit bandwidth to an arbitrary speed. The tool can change the link speed of the network adapter to one of a few link speeds that are supported by the stack, typically 10, 100, or 1000. If you want any values other than those, you need to use a different tool (I prefer tc). May 1, 2023 at 0:08
  • 1
    @MaximillianLaumeister - good call, added.
    – slm
    May 6, 2023 at 19:14
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.

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .