Let this script configure wondershaper queues for you automagically!

Project maintained by uriel1998 Hosted on GitHub Pages — Theme by mattgraham


A script in bash (with some assorted tools) to automagically shape network traffic using a modified version of the wondershaper script (and maintaining your high LAN network speeds).


  1. About
  2. License
  3. Prerequisites
  4. Installation
  5. Usage

1. About

A script in bash (with some assorted tools) to automagically shape network traffic using a modified version of the wondershaper script (and maintaining your high LAN network speeds). This is a per-machine setup.

It is designed to be run under Network Manager, but can be invoked manually (or from a cron job).

2. License

This project is licensed under the GNU general public license. For the full license, see LICENSE.

3. Prerequisites

These are probably already installed or are easily available from your distro:


4. Installation

ALL ALL=NOPASSWD:/sbin/wondershaper

Installing wondershaper

#IMPORTANT EDIT: Of course, it’s after I write all this up that someone points out to me that I was looking at an abandoned fork of wondershaper. Please utilize this version of wondershaper, and redownload my script, as the command line switches have changed, and I corrected for that. Still put it in /sbin, though, please.

The wondershaper script is rather old, and has one big glaring omission - it also rate-limits your LAN connectivity. My modified copy, using this guide, changes the rate limit for LAN traffic to 85% of a 10MB link for subnet 192.168.1.* . If your LAN subnet is different (or has a higher link speed), you will want to change those values.

You are free to utilize your distro’s package for wondershaper, or inspect and use my modified copy so that LAN traffic is shaped differently than internet traffic.

If you are using my script:

sudo cp ./ /sbin/wondershaper

This guide (and script) are written assuming that wondershaper is located in /sbin and is executable. So if you’re not using mine and are using your distro’s version, install it normally and then type:

sudo ln -s $(which wondershaper) /sbin/wondershaper

to create a symlink to /sbin/wondershaper if it does not yet exist.

Then make sure it’s executable:

sudo chmod a+x /sbin/wondershaper

To install autobandwidth for Network Manager, first type

sudo mkdir /etc/NetworkManager/dispatcher.d

so that the directory exists if it’s not already there. Then type

sudo cp ./ /etc/NetworkManager/dispatcher.d/60-autobandwidth

to copy the script. Then, finally,

sudo chown root:root /etc/NetworkManager/dispatcher.d/60-autobandwidth

If it isn’t owned by root, NetworkManager won’t touch it.

If you’re using it manually, copy it (or create a symlink to) somewhere in your $PATH.

5. Usage

If you have installed it properly and Network Manager is installed, it should run automagically when the interface changes. It will (if not specified by Network Manager) find the active link, measure bandwidth using speedtest-cli, and then shape your internet traffic to 85% of measured bandwidth.

It waits until the load is less than 2 before running; this is hardcoded in the script. It’s line 29: while (( $(echo "$MyLoad > 2" |bc -l) )); do.
Change 2 if you want or need to.

If you run autobandwidth without any arguments, it will look for links that are up. It will choose the first ethernet link first, and if there’s no wired connection, it will look for (and choose) the first wireless connection that is up.

IMPORTANT autobandwidth uses the eno[0-9] and wlp[0-9]s[0-9] interface naming conventions!

If you run autobandwidth quit manually, it will clear the existing queues on the automatically chosen link. If you wish to specify the link in question, try this: autobandwidth eno1 quit or autobandwidth wlp2s0 quit, replacing the link names with your own.

This might also be useful to run as a cronjob if your connection changes or is funky.

It will output a minimal result to /tmp/bandwidthqueues as well if you wish to use that data in conky, etc.

Steven Saus injects people with radioactivity for his day job, but only to serve the forces of good.