Skip to main content

Bandwidth manager for Linux

Project description

bwflow

Egress bandwidth manager for Linux. Tracks monthly traffic via vnstat and enforces rate limits using tc when your budget runs out.

How it works

At the start of each month, bwflow credits a configurable burst allowance (e.g. 50 GB) immediately. The remaining budget drips in continuously over the month. If egress exceeds the available tokens, a tc TBF rate limit is applied to your network interface. When the next month starts, the limit is lifted automatically.

Prerequisites

Package Purpose
vnstat ≥ 2.6 Traffic accounting (source of truth)
iproute2 (tc) Applies rate limits to the interface
Python ≥ 3.13 Runtime
# Ubuntu / Debian
sudo apt install vnstat iproute2

# Amazon Linux / RHEL
sudo yum install vnstat iproute2

# Alpine
apk add vnstat iproute2

Enable the vnstat daemon:

sudo systemctl enable --now vnstat

Installation

pip install bwflow

Verify:

bwflow --help

Quick start

1. Initialise (creates /etc/bwflow/config.toml, offers to patch vnstat.conf):

sudo bwflow init

2. Review the config:

# /etc/bwflow/config.toml

[bandwidth]
monthly_budget_gb = 100   # total monthly egress budget
pre_charge_gb = 50        # burst tokens available from day 1
billing_day = 1           # reset on the 1st of each month

[network]
interface = "eth0"        # interface to monitor and throttle

[daemon]
poll_interval_seconds = 15

3. Install and start the systemd service:

sudo cp /usr/local/lib/python3.x/site-packages/bwflow/contrib/bwflow.service \
     /etc/systemd/system/
# or from a source checkout:
sudo cp contrib/bwflow.service /etc/systemd/system/

sudo systemctl daemon-reload
sudo systemctl enable --now bwflow

4. Check logs:

journalctl -u bwflow -f

Commands

Command Description
sudo bwflow init First-time setup: config + vnstat.conf patch
sudo bwflow run Start the daemon (called by systemd)
bwflow report Show monthly traffic report
sudo bwflow run --verbose Debug logging (shows every 15 s tick)

Notes

  • billing_day must be 1 in v0.1 (calendar-month only). Arbitrary billing days are planned.
  • bwflow requires UseUTC 1 in /etc/vnstat.conf on non-UTC systems. bwflow init offers to patch this automatically.
  • Rate limiting uses Linux tc TBF (Token Bucket Filter) and requires CAP_NET_ADMIN. The simplest setup is to run as root; see contrib/bwflow.service for a least-privilege alternative.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bwflow-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bwflow-0.1.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file bwflow-0.1.0.tar.gz.

File metadata

  • Download URL: bwflow-0.1.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bwflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c757e3ff2ab6e04da9faf638cbc1464075255a045105106ad9e67e0d3324e8d4
MD5 ebe17a4844a15a3c9e0735d7040e2722
BLAKE2b-256 602a8aaece0c239d09546b5dea4e60c1fd9020ceef897098e1fc8d0f89ccd349

See more details on using hashes here.

File details

Details for the file bwflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bwflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bwflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fed3c409c4cd9836acd92f34eddc599cd6734ad6b4ce4fcf8a2eed6e31a589c
MD5 a3de15d96491af8de07cf49efe86ba2a
BLAKE2b-256 0ac68bce90cc8ca1869b1340dc46d300e5101257c81b7e920402eec6b5d8d618

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page