This tutorial will help you to easily limit network bandwidth and shape your network traffic in Kali
or any other operating system. By limiting the network bandwidth usage, you can save unnecessary bandwidth consumption by applications, such as package managers (Pacman, yum, apt), web browsers, torrent clients, download managers, or extensive scanning. Limiting bandwidth also prevents bandwidth abuse by 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.
Installation
Do not use the apt install command . It will install a non-functional old version.
git clone https://github.com/magnific0/wondershaper.git cd wondershaper sudo make install
Configuration
ip addr show # find the interface sudo wondershaper -c -a eth0 # clear previous configuration sudo wondershaper -a eth0 -u 10000 -d 8000 # set a limit in kilobits/s, ex. downloading 10 Mbps, uploading 8 Mbps
Persistent usage
Modify the /etc/systemd/wondershaper.conf
according to your needs.
# cat /etc/systemd/wondershaper.conf [wondershaper] # Adapter IFACE="eth0" # Download rate in Kbps DSPEED="50000" # Upload rate in Kbps USPEED="8000" ### Separate items by whitespace: #HIPRIODST=(IP1 IP2) HIPRIODST=() COMMONOPTIONS=() # low priority OUTGOING traffic - you can leave this blank if you want # low priority source netmasks NOPRIOHOSTSRC=(80); # low priority destination netmasks NOPRIOHOSTDST=(); # low priority source ports NOPRIOPORTSRC=(); # low priority destination ports NOPRIOPORTDST=(); ### EOF
To make sure wondershaper is reactivated on reboot a systemd service file is provided. First enable wondershaper as a systemd service using:
sudo systemctl enable --now wondershaper.service
Help Page
# wondershaper -h USAGE: /usr/sbin/wondershaper [-hcs] [-a <adapter>] [-d <rate>] [-u <rate>] Limit the bandwidth of an adapter OPTIONS: -h Show this message -a <adapter> Set the adapter -d <rate> Set maximum download rate (in Kbps) and/or -u <rate> Set maximum upload rate (in Kbps) -p Use presets in "/etc/systemd/wondershaper.conf" -c Clear the limits from adapter -s Show the current status of adapter -v Show the current version Configure HIPRIODST in "/etc/systemd/wondershaper.conf" for hosts requiring high priority i.e. in case ssh uses dport 443. MODES: wondershaper -a <adapter> -d <rate> -u <rate> wondershaper -c -a <adapter> wondershaper -s -a <adapter> EXAMPLES: wondershaper -a eth0 -d 1024 -u 512 wondershaper -a eth0 -u 512 wondershaper -c -a eth0