Home Linux Networking How To Limit Network Bandwidth In Linux Using Wondershaper

How To Limit Network Bandwidth In Linux Using Wondershaper

By sk
Published: Updated: 15.7K views

This tutorial will explain what is Wondershaper and how to easily limit network bandwidth and shape your network traffic in Linux and Unix operating systems.

What Is Wondershaper?

Wondershaper is 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.

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.

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.

Wondershaper utility is mainly designed for limiting the bandwidth of one or more network adapters in your local system. Let us now see how to install and 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 Paru or Yay.

$ paru -S wondershaper-git

Or,

$ yay -S wondershaper-git

On Debian, Ubuntu, Linux Mint:

$ sudo apt install wondershaper

On Fedora:

$ sudo dnf install wondershaper

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

$ sudo dnf install epel-release
$ sudo dnf 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:

Download rate before enabling Wondershaper

Download rate before enabling Wondershaper

After enabling Wondershaper:

Download rate after enabling wondershaper

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:

You May Also Like

4 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
jose February 10, 2022 - 12:38 am

Hello, this post was very useful. I was able to install the modem, I ask you, do you know any application or command for raspberry with which I can check the internet traffic of my network? because it is consuming 3gb per day. I only have rasp with teamviewer, and a camera, but I hardly even access it. Thanks a lot.

Reply
sk February 10, 2022 - 11:34 am

There are many tools exists for this purpose. We already have documented about Netdata, Doppler and Vnstat.

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. By using this site, we will assume that you're OK with it. Accept Read More