Throttle Network Traffic Linux
With Christmas time here, my family is around quite a lot. This leads to many playing games on internet. If you need to download a large file with bandwidth concerns there is a very simple tool that can help. The command wondershaper
will throttle based on an interface.
Installation
sudo apt update && sudo apt install -y wondershaper
Preparation
We need to find the interface you need to throttle. Run the following to see which interface works for you.
dan@ubuntu-test:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 34:2e:b7:11:94:87 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.24/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp0s20f3
valid_lft 86307sec preferred_lft 86307sec
inet6 fe80::87bc:5bbd:736d:a119/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:37:a5:0d brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: vmnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
inet 172.16.184.1/24 brd 172.16.184.255 scope global vmnet1
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fec0:1/64 scope link
valid_lft forever preferred_lft forever
5: vmnet8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
inet 172.16.196.1/24 brd 172.16.196.255 scope global vmnet8
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fec0:8/64 scope link
valid_lft forever preferred_lft forever
For me I will use wlp0s20f3
Throttling
Now we need to throttle. This will set download to 1024 Kb and upload to 256 Kb.
sudo wondershaper wlp0s20f3 10240 256
Now you can throttle all traffic on your laptop.
Clearing Settings
After you are done throttling a connection you can remove the cap by running the clear argument with wondershaper.
sudo wondershaper clear wlp0s20f3