Categories: LinuxShellUbuntu

How to Limit Network Bandwidth in Ubuntu

Most of the time while downloading large files from the internet, you don’t want to disturb the rest of the network from congestion as most of the network bandwidth will be consumed by the one process.

In this article, we will see how to limit network bandwidth in Ubuntu 18.04 LTS using Wondershaper. Wondershaper is a command line utility that helps to limit the bandwidth usage by saving unnecessary bandwidth consumption. Using Wondershaper, you can set the maximum upload and download rate on a specific network interface.

Limit Bandwidth Using Wondershaper

In this section, we will see how to install Wondershaper using Ubuntu Terminal

Step 1: Open the Terminal

In order to install the Wondershaper utility, we will use the Ubuntu Terminal. You can open the Terminal using the search bar in Application Launcher. Alternatively, you can use the shortcut by pressing Ctrl+Alt+T key combinations to launch the Terminal.

Step2: Installing Wondershaper

Wondershaper is available in the official Ubuntu repositories. In the Terminal, run the below command as sudo to install Wondershaper

$ sudo apt-get install wondershaper

There is an alternative method to install Wondershaper in case if you want to have Wondershaper with the latest updates. I am using this method for describing the procedure.

Navigate to the directory using cd command in Terminal.

$ cd /bin

Then add the below command:

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

Navigate to Wondershaper directory and install it using the below command as sudo:

$ cd wondershaper
sudo make install

Step 3: Enable and start the service

Once you have done with the installation, enable the service to allow it to start every time automatically when the system boots. Note that Wondershaper can be run as service similar to other services in Ubuntu.

After enabling the service, also start the service to use it at the current time.

Run the below commands as sudo in the Terminal to enable and start the Wondershaper service:

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

Step 4: Verify service

You can verify if the Wondershaper service is active by running the below command as sudo:

$ sudo systemctl status wondershaper.service

In case you want to stop the service, run the below command:

$ sudo systemctl stop wondershaper.service

In case there is a problem with service and you want to restart it, run the below command:

$ sudo systemctl restart wondershaper.service

Step 5: Use Wondershaper

Find the name of the interface on which you want to limit the bandwidth.

You can find the interface name using one of the following commands:

$ ifconfig

$ ip link show

$ ip addr

To limit the bandwidth for a specific interface, run the command in following syntax:

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

-a: defines interface name

-d: defines download rate in kbps

-u: defines upload rate in kbps

For instance, I want to limit bandwidth for interface eth0 to be 1024kbps for download and 512 kbps for upload, I will run this command:

To clear or remove the bandwidth limits from an interface, run the command s sudo in below syntax:

$ sudo wondershaper -c –a <interface>

If you have installed Wondershaper using GitHub repository, then there is a configuration file wonderhsaper.conf at /etc/conf.d. You can edit using any text editor.

I am using Nano editor to edit that configuration file. Run the below command in the Terminal window:

$ sudo nano /etc/conf.d/wondershaper.conf

Here you can set the interface and define the upload and download bandwidth limit. When done with configurations, save the file and exit.

Make sure to restart the Wondershaper service after making changes in the configuration file.

So that was the simplest way using which you can limit network bandwidth and ensure congestion free network traffic by preventing one single user to consume all the bandwidth.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago