Home Command line utilities How To Limit Network Bandwidth In Linux Using Wondershaper
Limit Network Bandwidth In Linux Using Wondershaper

How To Limit Network Bandwidth In Linux Using Wondershaper

By sk
1089 Views

This tutorial will help you to easily limit network bandwidth and shape your network traffic in Linux and Unix operating systems. By limiting the network bandwidth usage, you can save unnecessary bandwidth consumption's by applications, such as package managers (pacman, yum, apt), web browsers, torrent clients, download managers. Limiting bandwidth also prevents the bandwidth abuse by a single or multiple users in the network. Say hello to Wondershaper, a simple script to limit the bandwidth of your system's network adapter(s). It limits the bandwidth using iproute's tc command, but greatly simplifies its operation. Wondershaper is one of the easiest and quickest solution ever I have come across to limit the Internet or local network bandwidth usage.

Please be mindful that Wondershaper can only limit the incoming and outgoing traffic of your local network interfaces, not the interfaces of your router or modem. In other words, Wondershaper will only limit the network bandwidth in your local system itself, not any other systems in the network. This utility is mainly designed for limiting the bandwidth of one or more network adapters in your local system. Let us see how to use Wondershaper to shape the network traffic.

Install Wondershaper in Linux

To install the latest version, git clone wondershaper repository:

$ git clone  https://github.com/magnific0/wondershaper.git

Go to the wondershaper directory and install it as show below

$ cd wondershaper
$ sudo make install

And, run the following command to start wondershaper service automatically on every reboot.

$ sudo systemctl enable wondershaper.service
$ sudo systemctl start wondershaper.service

You can also install using your distribution's package manager (official or non-official).

Wondershaper is available in AUR, so you can install it in Arch-based systems using AUR helper programs such as Yay.

$ yay -S wondershaper-git

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install wondershaper

On Fedora:

$ sudo dnf install wondershaper

On RHEL, CentOS, enable EPEL repository and install wondershaper as shown below.

$ sudo yum install epel-release
$ sudo yum install wondershaper

Finally, start wondershaper service automatically on every reboot.

$ sudo systemctl enable wondershaper.service
$ sudo systemctl start wondershaper.service

Limit Network Bandwidth In Linux Using Wondershaper

First, find the name of your network interface. Here are some common ways to find the details of a network card.

$ ip addr
$ route
$ ifconfig

Once you find the network card name, you can limit the bandwidth rate as shown below.

$ sudo wondershaper -a <adapter> -d <rate> -u <rate>

For instance, if your network card name is enp0s8 and you wanted to limit the bandwidth to 1024 Kbps for downloads and 512 kbps for uploads, the command would be:

$ sudo wondershaper -a enp0s8 -d 1024 -u 512

Where,

  • -a : network card name
  • -d : download rate
  • -u : upload rate

To clear the limits from a network adapter, simply run:

$ sudo wondershaper -c -a enp0s8

Or

$ sudo wondershaper -c enp0s8

Just in case, there are more than one network card available in your system, you need to manually set the download/upload rates for each network interface card as described above.

If you have installed Wondershaper by cloning its GitHub repository, there is a configuration file named wondershaper.conf exists in /etc/conf.d/ location. Make sure you have set the download or upload rates by modifying the appropriate values(network card name, download/upload rate) in this file.

$ sudo nano /etc/conf.d/wondershaper.conf
[wondershaper]
# Adapter
#
IFACE="eth0"

# Download rate in Kbps
#
DSPEED="2048"

# Upload rate in Kbps
#
USPEED="512"

Here is the sample before Wondershaper:

wondershaper 1

Download rate before enabling Wondershaper

After enabling Wondershaper:

wondershaper 2

Download rate after enabling wondershaper

As you can see, the download rate has been tremendously reduced after limiting the bandwidth using Wondershaper in my Ubuntu 18.04 LTS server.


Suggested read:


For more details, view the help section by running the following command:

$ wondershaper -h

Or, refer man pages.

$ man wondershaper

As far as tested, Wondershaper worked just fine as described above. Give it a try and let us know what do you think about this utility.

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

2 comments

Gert September 9, 2018 - 12:26 pm

Is it possibile to limit network bandwidth for a particular mac address?

Reply
Dave taht September 10, 2018 - 8:45 am Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More