Hello, there. I created a (mildly sloppy) prioritization script some time ago that looks somewhat like this:
Code:
prioritize()
{
export PORT=$1
export PROTOCOL=$2
export TYPE=$3
export PRIORITY=$4
export MESSAGE=$5
case "$PRIORITY" in
"high")
PRIORITY="1:1"
;;
"normal")
PRIORITY="1:2"
;;
"low")
PRIORITY="1:3"
;;
esac
if [ "$TYPE" = "src" -o "$TYPE" = "both" ]; then
$IPTABLES -t mangle -A POSTROUTING -p $PROTOCOL --sport $PORT -j CLASSIFY --set-class $PRIORITY
fi
if [ "$TYPE" = "dst" -o "$TYPE" = "both" ]; then
$IPTABLES -t mangle -A POSTROUTING -p $PROTOCOL --dport $PORT -j CLASSIFY --set-class $PRIORITY
fi
}
tc qdisc add dev $EXT_IFC root handle 1: prio
tc qdisc add dev $EXT_IFC parent 1:1 handle 10: sfq
tc qdisc add dev $EXT_IFC parent 1:2 handle 20: sfq
tc qdisc add dev $EXT_IFC parent 1:3 handle 30: tbf rate 650kbit burst 2048 latency 50ms
prioritize 1:65535 tcp both low
prioritize 1:65535 udp both low
$IPTABLES -t mangle -A POSTROUTING -p tcp --tcp-flags ALL ACK -m state --state ESTABLISHED -m length --length 40:100 -j CLASSIFY --set-class 1:1
prioritize 22000 tcp src high
prioritize 80 tcp both normal
prioritize 6112 udp both normal
prioritize 4000 tcp both normal
...
It's not the most elegant thing ever created but it has successfully prioritized traffic on my network for more than a year.
However, we have recently obtained a total of seven external static IP addresses and I am now trying to accomplish some more complex routing. The complicating element is the fact that my external interface (eth0) now has an additional six incarnations (eth0:0, eth0:1, ..., eth0:5) to accomodate the new IP addresses. As a result, the tc qdisc lines show above aren't sufficient; they only shape eth0's traffic and not the traffic on the other interfaces.
Creating a new set of qdiscs for the other interfaces doesn't seem to be a good approach either. Our connection is a 1.5Mb/768Kb cable line; hence, handle "30:" above is capped at 650Kbit. This is designed to prevent non-interactive connections (FTP transfers, BitTorrent clients, Windows Update, etc.) from consuming the entire upstream and killing any chance we have of sending ACK packets or sending data for more interactive tasks (web browsing, SSH, Diablo II, etc.). For this reason, I would like to be able to shape all of the traffic leaving on any of these interfaces (eth0, eth0:0, ..., eth0:5) using the same set of qdiscs.
So, the question is: how do I do this? Any references to documents or whatnot which may help me in solving this problem would be appreciated.
Thanks!