htb-total script:
/sbin/ifconfig > /root/ifconfig_file
2>/dev/null
if grep ppp0 /root/ifconfig_file > /dev/null
then
echo ppp0
IF=ppp0
else
echo ppp1
IF=ppp1
fi
CEIL=240
/sbin/tc qdisc add dev $IF root handle 1: htb default 15 r2q 1
/sbin/tc class add dev $IF parent 1:1 classid 1:1 htb rate ${CEIL}kbit ceil ${CEIL}kbit
/sbin/tc class add dev $IF parent 1:1 classid 1:10 htb rate 80kbit ceil 80kbit prio
0
/sbin/tc class add dev $IF parent 1:1 classid 1:11 htb rate 80kbit ceil ${CEIL}kbit
prio 1
/sbin/tc class add dev $IF parent 1:1 classid 1:12 htb rate 20kbit ceil ${CEIL}kbit
prio 2
/sbin/tc class add dev $IF parent 1:1 classid 1:13 htb rate 20kbit ceil ${CEIL}kbit
prio 2
/sbin/tc class add dev $IF parent 1:1 classid 1:14 htb rate 10kbit ceil ${CEIL}kbit
prio 3
/sbin/tc class add dev $IF parent 1:1 classid 1:15 htb rate 30kbit ceil ${CEIL}kbit
prio 3
/sbin/tc qdisc add dev $IF parent 1:12 handle 120: sfq perturb 10
/sbin/tc qdisc add dev $IF parent 1:13 handle 130: sfq perturb 10
/sbin/tc qdisc add dev $IF parent 1:14 handle 140: sfq perturb 10
/sbin/tc qdisc add dev $IF parent 1:15 handle 150: sfq perturb 10
#2:
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 1 handle 1 fw classid 1:10
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 2 handle 2 fw classid 1:11
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 3 handle 3 fw classid 1:12
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 4 handle 4 fw classid 1:13
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 5 handle 5 fw classid 1:14
/sbin/tc filter add dev $IF parent 1:0 protocol ip prio 6 handle 6 fw classid 1:15
#4:
/sbin/iptables -t mangle -A PREROUTING -p icmp -j MARK --set-mark 0x1
/sbin/iptables -t mangle -A PREROUTING -p icmp -j RETURN
#5:
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark
0x1
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j RETURN
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j MARK --set-mark
0x5
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Minimize-Cost -j RETURN
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j MARK
--set-mark 0x6
/sbin/iptables -t mangle -A PREROUTING -m tos --tos Maximize-Throughput -j RETURN
#Now prioritize ssh packets:
/sbin/iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j MARK --set-mark
0x1
/sbin/iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j RETURN
#web:
/sbin/iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 80 -j MARK --set-mark
0x1
/sbin/iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 80 -j RETURN
#smtp
#iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 25 -j MARK --set-mark 0x1
#iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 25 -j RETURN
#prioritize packets to begin tcp connections, those with SYN flag set:
/sbin/iptables -t mangle -I PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN
-j MARK --set-mark 0x1
/sbin/iptables -t mangle -I PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN
-j RETURN
#adding rules to PREROUTING in mangle, we terminate the PREROUTING table with:
/sbin/iptables -t mangle -A PREROUTING -j MARK --set-mark 0x6
|