#!/bin/sh RATE=192 IFACE=eth0 # This can't be called "GROUPS" - why? GRPS=4 BANDS=3 IP[1]=192.168.0.1 IP[2]=192.168.0.2 IP[3]=192.168.0.3 IP[4]=192.168.0.0/0 echo "Setting throttling to ${RATE}kbit on ${IFACE}..." # Setup the marking (we're going backwards) for grp in $(seq ${GRPS} 1); do ip=${IP[${grp}]} # Send all unclasified traffic to classes with lowest priority iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -j MARK --set-mark ${grp}${BANDS} # Mark the packets according to their importance iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -p tcp --sport 22 -j MARK --set-mark ${grp}2 iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -p tcp --dport 22 -j MARK --set-mark ${grp}2 iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j MARK --set-mark ${grp}2 iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -p ! tcp -j MARK --set-mark ${grp}2 iptables -t mangle -A FORWARD -o ${IFACE} -d ${ip} -p icmp -j MARK --set-mark ${grp}1 # The proxy server complication (send to lowest priority) iptables -t mangle -A OUTPUT -o ${IFACE} -d ${ip} -p tcp --sport 3128 -j MARK --set-mark ${grp}${BANDS} done IFACE=${IFACE} RATE=${RATE} GRPS=${GRPS} BANDS=${BANDS} ./shaping-buildtree