#!/bin/sh
# this is the main configuration file for throttled.
# if you used a previous release, the syntax has changed slightly in 0.4.x
# you have been warned. make sure to check the -r flag.
# set your network interface
# you can get a full list by doing "ifconfig -a"
# these examples are osx specific
# ethernet - "INTERFACE=en0"
# airport - "INTERFACE=en1"
# pppoe - "INTERFACE=ppp0"
INTERFACE=en0
# set your maximum speed in bytes...
# this should be set to your maximum upstream speed.
# recommended common adsl/cable speeds:
# 384k upload - "MAXSPEED=49152"
# 256k upload - "MAXSPEED=32768"
# 128k upload - "MAXSPEED=16384"
MAXSPEED=49152
# DON'T CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOUR DOING.
# most users should not edit anything below. you have been warned.
# ipfw rule number
# this allows throttled to coexist with the apple firewall
# ipfw can only accept rules between 1-65535
# if I were you would keep this at 07000
RULENUM=07000
# usage: throttled [-ATLh] -s speed -r rule [-d port] [-p priority] [-i increment]
# -s speed Max speed in bytes/second (required)
# -r rule IPFW rule number to remove when quit (required)
# -i increment Amount to change the throttle in bytes/sec (based on signal USR1 and USR2) (optional)
# -A Disable ACK packet priority (not recommended)
# -L Throttle local network (192.168.x.x and 10.x.x.x) (optional - this can be accomplished with firewall rules also)
# -T Enable iTunes TTL fix
# -h This help screen
# -d port Divert port (optional, may specify more than one)
# -p priority Priority for the divert port specified prior to this option.
# launch throttled with a maxspeed of $MAXSPEED
# this throttled instance has 2 priorities, this allows us to prioritize low
# bandwidth services.
# You will understand this more when you look how the rules are setup below.
/usr/local/sbin/throttled -s $MAXSPEED -r $RULENUM -d 17778 -p 1 -d 17777 -p 2 -T
# all rules below are for ipfw, there is many ways you can set this up.
# we have simplified this for new users by removing ip specific ipfw rules.
# this fixes isses for dynamic ip users, but if you want rules bound to
# a single ip you can use either of the examples below.
#
# the line below finds your ip automatically
# IP=$(/sbin/ifconfig $INTERFACE inet | /usr/bin/sed -n 's/^.*inet\ \(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p' | tail -n 1)
#
# you can also specify the ip address by doing
# IP=192.168.1.7
IP=any
# default prioritized configuration (wincent.org style config)
# these rules allow http/https/ssh/telnet/smtp/aim/pop/irc/sirc
# to be prioritized by the throttle.
#
# Setting up the configuration this way catches more file transfer types
# and minimizes lag in response driven services.
# prioritize nameserver lookups
/sbin/ipfw add $RULENUM divert 17778 ip from $IP to any 53 out xmit $INTERFACE
# prioritize http/https
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 80 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 443 out xmit $INTERFACE
# prioritize ssh and telnet
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 22 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 22 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 23 out xmit $INTERFACE
# prioritize imap and smtp
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 143 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 25 out xmit $INTERFACE
# prioritize ftp directory listings
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 21 out xmit $INTERFACE
# prioritize aim or iChat
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 5190 out xmit $INTERFACE
# prioritize msn
# /sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 1863 out xmit $INTERFACE
# prioritize pop3
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 110 out xmit $INTERFACE
# prioritize irc and sirc
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 6667 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 6668 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 9999 out xmit $INTERFACE
# prioritize hotline, carracho, wired "listing" ports (client end)
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 5500 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 6700 out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 2000 out xmit $INTERFACE
# prioritize hotline and carracho "listing" ports (server end)
# /sbin/ipfw add $RULENUM divert 17778 tcp from $IP 5500 to any out xmit $INTERFACE
# /sbin/ipfw add $RULENUM divert 17778 tcp from $IP 6700 to any out xmit $INTERFACE
# prioritize VNC
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 5900 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 5900 out xmit $INTERFACE
# prioritize iTunes
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 3689 to any out xmit $INTERFACE
# prioritize Gizmo
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 5004 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 5060 to any out xmit $INTERFACE
# prioritize WoW
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP to any 3724 out xmit $INTERFACE
# prioritize Diablo II, Starcraft, Warcraft II, and Warcraft III
/sbin/ipfw add $RULENUM divert 17778 ip from $IP 6112-6119 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 4000 to any out xmit $INTERFACE
# prioritize Unreal Tournament 2004
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 28902 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 7777-7778 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 7787 to any out xmit $INTERFACE
# prioritize Call of Duty
/sbin/ipfw add $RULENUM divert 17778 ip from $IP 28960 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 20500 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 20510 to any out xmit $INTERFACE
# prioritize Quake 3
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 27660-27665 to any out xmit $INTERFACE
# prioritize Ghost Recon
/sbin/ipfw add $RULENUM divert 17778 tcp from $IP 2346 to any out xmit $INTERFACE
/sbin/ipfw add $RULENUM divert 17778 udp from $IP 2347-2348 to any out xmit $INTERFACE
# bind to throttle low priority services.
/sbin/ipfw add $RULENUM divert 17777 ip from $IP to any out xmit $INTERFACE
# ALL RULES BELOW THIS POINT ARE SAMPLES FOR OTHER CONFIGURATIONS
# YOU PROBABLY DON'T WANT TO EDIT BEYOND THIS POINT
# if your only interested in capping one service, or specific services
# use the rules below. if you are using these make sure to remove
# the second divert port (17778) in throttled above and any related
# ipfw divert lines. you have been warned.
# bind for kdx server
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 10700 to any out xmit $INTERFACE
# bind for kdx client uploads
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP to any 10700 out xmit $INTERFACE
# bind for carracho server
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 6701 to any out xmit $INTERFACE
# bind for carracho client uploads
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP to any 6701 out xmit $INTERFACE
# bind for hotline server
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 5501 to any out xmit $INTERFACE
# bind for hotline client uploads
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP to any 5501 out xmit $INTERFACE
# bind for Limewire
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 6346 to any out xmit $INTERFACE
# bind for Aquisition
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 5634 to any out xmit $INTERFACE
# bind for mldonkey
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 4662 to any out xmit $INTERFACE
# /sbin/ipfw add $RULENUM divert 17777 udp from $IP 4666 to any out xmit $INTERFACE
# bind ports for bittorrent
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 6881-6889 to any out xmit $INTERFACE
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP to any 6881-6889 out xmit $INTERFACE
# bind a few ports for dcc connections
# /sbin/ipfw add $RULENUM divert 17777 tcp from $IP 1024-1028 to any out xmit $INTERFACE
# sample second throttle with divert port 5555 and throttle of 5k/sec
# use this if you want to cap another service at a different speed
# /usr/local/sbin/throttled -s 5120 -d 5555
# /sbin/ipfw add $RULENUM divert 5555 tcp from $IP 80 to any out xmit $INTERFACE
syntax highlighted by Code2HTML, v. 0.9.1