Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created April 20, 2011 14:10
Show Gist options
  • Save jhsu/931423 to your computer and use it in GitHub Desktop.
Save jhsu/931423 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -v
# initial setup
tc qdisc del dev eth0 root # clear eth0
tc qdisc add dev eth0 root handle 2 htb default 1 # set default class
iptables -N TRAFFIC_ACCT
iptables -I INPUT -j TRAFFIC_ACCT # or FORWARD
iptables -A TRAFFIC_ACCT -p tcp
iptables -A TRAFFIC_ACCT -p udp
iptables -A TRAFFIC_ACCT -p icmp
# view
iptables -L TRAFFIC_ACCT -n -v -x
# iptables -Z TRAFFIC_ACCT # Zero out counters
# iptables -F TRAFFIC_ACCT # Remove all rules for chain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment