How to Control Bandwidth in Linux Using Trickle and WonderShaper

Managing bandwidth effectively on Linux systems is crucial, especially when you’re working with multiple machines or servers. Whether you’re running a dedicated or shared server, controlling the bandwidth helps prevent any one application or download from consuming all the network resources, ensuring fair usage across other users. This article explores two simple tools—WonderShaper and Trickle—that allow easy bandwidth management on Linux.

Limiting Bandwidth Using WonderShaper

WonderShaper is a lightweight tool that simplifies the process of limiting the bandwidth for a specific network interface on a Linux machine. It enables you to control both download and upload speeds with separate values for each interface.

Installation:

For Debian/Ubuntu:

sudo apt-get install wondershaper

For CentOS/RHEL:

sudo yum install wondershaper

Usage:

The basic syntax for using WonderShaper is:

wondershaper [interface] [download_rate] [upload_rate]

Note: The rates are in kilobits per second (kbps), not kilobytes.

For example, to limit the download speed to 1 MB/s and upload to 200 KB/s on the eth0 interface, run:

wondershaper eth0 8192 1600

(Here, 1 MB = 8192 kilobits and 200 KB = 1600 kilobits)

Removing the Limitation:

To remove the restrictions on a specific interface (e.g., eth0), use the command:

wondershaper clear eth0

This will restore the interface to its original unrestricted state.

Limiting Bandwidth Using Trickle

Trickle is another tool for limiting bandwidth, but it works a bit differently from WonderShaper. It allows you to control bandwidth for a specific command, so it’s ideal for ad-hoc usage.

Installation:

For Debian/Ubuntu:

sudo apt-get install trickle

For CentOS/RHEL:

sudo yum install trickle

Usage:

You can use Trickle to limit the bandwidth of specific commands. For example, to download a file using wget while limiting the download speed to 10 KB/s, use:

trickle -d 10 wget https://example.com/file.zip

To limit both upload and download speeds, use the following syntax:

trickle -d 10 -u 20 scp file.zip user@remote:/path/to/destination

This command limits the download speed to 10 KB/s and upload speed to 20 KB/s for the scp operation.

Running Trickle in Daemon Mode:

If you want Trickle to automatically apply bandwidth limitations without needing to specify them each time, you can run it in daemon mode. For example, to set a limit of 20 KB/s for downloading and no upload limit:

trickled -d 20

Now, any command run with trickle will apply this bandwidth limit. For instance:

trickle wget https://example.com/file.zip

Without the trickle command in front, no limitation will apply.

Conclusion

Both WonderShaper and Trickle are simple yet effective tools for managing bandwidth on Linux systems. Whether you need to limit bandwidth per interface (WonderShaper) or restrict bandwidth for specific commands (Trickle), these tools help optimize network usage, particularly in shared environments. If bandwidth is scarce and multiple users share the network, these tools will be extremely beneficial. For more info visit host.co.in