Hello,
I have this problem: at home I have an internet link with 1024 kb/s downstream si 256 kb/s upstream on my personal computer, to this link I like to apply some traffic shaping per ports, for the upload part I do something like this and it works fine:
Code:
tc qdisc add dev $IF root handle 1: htb default 12
tc class add dev $IF parent 1: classid 1:1 htb rate ${CEIL}kbit ceil ${CEIL}kbit
tc class add dev $IF parent 1:1 classid 1:10 htb rate 80kbit ceil ${CEIL}kbit prio 1
tc class add dev $IF parent 1:1 classid 1:11 htb rate 108kbit ceil ${CEIL}kbit prio 2
tc class add dev $IF parent 1:1 classid 1:12 htb rate 8kbit ceil ${CEIL}kbit prio 3
$iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 22 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 22 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 65125 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 65125 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --tcp-flags SYN,RST,ACK SYN,FIN -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 53 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 80 -j MARK --set-mark 1
tc filter add dev $IF parent 1: protocol ip handle 1 fw classid 1:10
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 25 -j MARK --set-mark 2
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 110 -j MARK --set-mark 2
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 143 -j MARK --set-mark 2
tc filter add dev $IF parent 1: protocol ip handle 2 fw classid 1:11
The problem is for the download part because I cant sperate the traffic per ports, this without using (i have my reasons)IMQ or htb-init found on sourceforge, for download at the moment I user what tc offers me for ingress (read in man tc):
Code:
tc qdisc del dev $IF ingress
tc qdisc add dev $IF handle ffff: ingress
tc filter add dev $IF parent ffff: protocol ip prio 10 u32 match \
ip src 0.0.0.0/0 police rate 948kbit burst 80kbit drop flowid :1