#!/bin/bash
tc qdisc del dev eth0 root 2> /dev/null
 
tc qdisc add dev eth0 handle 1:0 root htb default 13
tc class add dev eth0 classid 1:1 root htb rate 500kbit ceil 500kbit
tc class add dev eth0 classid 1:10 parent 1:1 htb rate 100kbit ceil 500kbit prio 1
tc class add dev eth0 classid 1:11 parent 1:1 htb rate 100kbit ceil 500kbit prio 2
tc class add dev eth0 classid 1:12 parent 1:1 htb rate 250kbit ceil 500kbit prio 2
tc class add dev eth0 classid 1:13 parent 1:1 htb rate 50kbit ceil 500kbit prio 3
 
tc qdisc add dev eth0 handle 10:0 parent 1:10 sfq perturb 5
tc qdisc add dev eth0 handle 11:0 parent 1:11 sfq perturb 5
tc qdisc add dev eth0 handle 12:0 parent 1:12 sfq perturb 5
tc qdisc add dev eth0 handle 13:0 parent 1:13 sfq perturb 5
 
tc filter add dev eth0 pref 1 protocol ip handle 10 fw flowid 1:10
tc filter add dev eth0 pref 1 protocol ip handle 11 fw flowid 1:11
tc filter add dev eth0 pref 1 protocol ip handle 12 fw flowid 1:12
 
 
 
#iptables -t mangle -A POSTROUTING -p icmp -j MARK --set-mark 12
#acki
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags ACK ACK -j MARK --set-mark 10
 
#male ssh (?)
 
for i in 22 25 80 110 143 443 465 587 993 995; do 
  iptables -t mangle -A POSTROUTING -p tcp --dport $i -j MARK --set-mark 12
done
for i in 53; do 
  iptables -t mangle -A POSTROUTING -p udp --dport $i -j MARK --set-mark 12
done