#! /bin/bash
/sbin/tc qdisc del dev eth0 root # remove all rules.
/sbin/tc qdisc add dev eth0 root handle 1:0 htb default 10
/sbin/tc class add dev eth0 parent 1:0 classid 1:10 htb rate 80kbps ceil 90kbps prio 0 # rate 80k, top 90k
/sbin/iptables -A OUTPUT -t mangle -p tcp --sport XXXX -j MARK --set-mark 10 # apply rule on port XXXX
/sbin/service iptables save
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
# add this script to /etc/rc.local, which will run afte reboot automatically.