Skip to content

Instantly share code, notes, and snippets.

@Dynalon
Created January 22, 2013 21:32
Show Gist options
  • Save Dynalon/4598632 to your computer and use it in GitHub Desktop.
Save Dynalon/4598632 to your computer and use it in GitHub Desktop.
#!/bin/bash
NET=10.0.0.0/16
# i.e. 256Kbit/s
RATE_OUT=$1
# i.e. 6Mbit/s
RATE_IN=$2
DELAY_IN=$3
DELAY_OUT=$4
# modprobe stuff
#insmod "/home/s_doerr/ipfw3-2012/kipfw-mod/ipfw_mod.ko" > /dev/null >&2
IPFW=`which ipfw`
# flush any previous rules
yes | $IPFW flush
#$IPFW add pipe 3 in src-ip $NET { proto tcp or proto udp }
#$IPFW add pipe 4 out dst-ip $NET { proto tcp or proto udp }
$IPFW add pipe 3 in src-ip $NET proto all
$IPFW add pipe 4 out src-ip $NET proto all
$IPFW pipe 3 config bw $RATE_IN queue 20 delay $DELAY_IN
$IPFW pipe 4 config bw $RATE_OUT queue 20 delay $DELAY_OUT
# shou pipe confi
ipfw pipe 3 show
ipfw pipe 4 show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment