DEV Community

AHMED OSAMA
AHMED OSAMA

Posted on

How to control [limit] network bandwidth in linux 🐢

this article will help you limit your network bandwidth using wondershaper tool !!

Why to limit bandwidth?

there are a lot of reasons you would do that,
it is very useful when you are trying to :

  1. control your internet quota or
  2. throttle internet connection to know how certain app or service work on slow connections .
  3. have more than one wifi adapter and need to control the speed each one connects to internet
  4. any other reason IDK about 🤷🏻‍♂ !

so here we go

1. install wonder shaper tool



sudo apt install wondershaper  [On Debian/Ubuntu]
sudo yum install wondershaper  [On CentOS/RHEL]
sudo dnf install wondershaper  [On Fedora 22+]
sudo pacman -S wondershaper [ on Archlinux and based systems]


Enter fullscreen mode Exit fullscreen mode

2. find your interface name

you need to find your wifi card id that you will limit by running this command



ifconfig


Enter fullscreen mode Exit fullscreen mode

output will be like



br-85a34b55f6de: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
... other stuff 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
... other stuff 


wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
... other stuff 



Enter fullscreen mode Exit fullscreen mode

so here my wifi adapter name is 'wlp2s0' and lo is wired ethernet , you should know the one you need by other info like the ip or data usage , but if you have one wifi adapter it is usually wlp2s0.

3. run this command with your adapter name



sudo wondershaper -a wlp2s0 -d 4000 -u 1024


Enter fullscreen mode Exit fullscreen mode

with the -d argument represents download speed in kb and -u represents upload speed in kb

4. to clear the limit and have full internet speed you run



sudo wondershaper -c -a wlp2s0


Enter fullscreen mode Exit fullscreen mode

you also need to run this command before applying any new limit on the same adapter

5. I've made shell scripts to help you switch easily between high speed and low speed

you can find them in 👉🏻 this gist

Top comments (0)