Skip to content

Instantly share code, notes, and snippets.

@MaxMatti
Last active January 27, 2021 20:55
Show Gist options
  • Save MaxMatti/49fdcad2d089a3da7425ac95dea5d2e0 to your computer and use it in GitHub Desktop.
Save MaxMatti/49fdcad2d089a3da7425ac95dea5d2e0 to your computer and use it in GitHub Desktop.
This script monitors the incoming and outgoing bandwidth of a server on localhost.
#!/usr/bin/env bash
SERVERPORT=$1
sudo iptables -A INPUT -p tcp --dport "$SERVERPORT"
sudo iptables -A OUTPUT -p tcp --sport "$SERVERPORT"
watch -n 1 sudo iptables -n -L -v -Z
sudo iptables -D INPUT -p tcp --dport "$SERVERPORT"
sudo iptables -D OUTPUT -p tcp --sport "$SERVERPORT"
@MaxMatti
Copy link
Author

Note: This measures the bandwidth to/from all clients combined. To see each client separately, check out this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment