All pastes #1037865 Raw Edit

hisham

public shellscript v1 · immutable
#1037865 ·published 2008-06-03 16:55 UTC
rendered paste body
[@ryu]12:53PM ~ > cat ~/bin/choke#!/bin/bash# change these values to suit your needsETHERNET_DEVICE="eth1"LINK_SPEED="102400Kbit"UPLOAD_SPEED="500Kbit"PORT="80"echo -n "Limiting poor bastards on port $PORT to $UPLOAD_SPEED..."# delete previous root nodetc qdisc del dev $ETHERNET_DEVICE root# create root nodetc qdisc add dev $ETHERNET_DEVICE root handle 1: htb default 11# create LINK classtc class add dev $ETHERNET_DEVICE parent 1: classid 1:1 htb rate $LINK_SPEED# create our HTTP shaping classtc class add dev $ETHERNET_DEVICE parent 1:1 classid 1:10 htb rate $UPLOAD_SPEED# create our REST class for unutilized bandwidthtc class add dev $ETHERNET_DEVICE parent 1:1 classid 1:11 htb rate $LINK_SPEED# create the filter for the HTTP class, we filter on source port 80 (http)tc filter add dev $ETHERNET_DEVICE protocol ip parent 1:0 prio 1 u32 match ip sport $PORT 0xffff flowid 1:10echo "   [DONE]";