You are not logged in.

#1 2012-08-20 00:42:06

Enverex
Member
From: UK
Registered: 2007-06-13
Posts: 159
Website

Managing Downstream with IPTables and HTB

I'm trying to use packet filtering to manage my downstream connection so that services get bandwidth based on their ports, i.e. Newsgroups get the least, DNS/SSH get the most, etc, when they are all trying to work at the same time.

The guides strewn across the net for filtering like this are an absolute nightmare, bits and pieces here and there, all generally very old.

This is what I'm currently using, but it seems to be putting ALL traffic into 1:20 rather than where it should be going:

iptables -t mangle -F
iptables -t mangle -A PREROUTING -i wan0 -p tcp -m tcp --dport 222 -j MARK --set-xmark 10
iptables -t mangle -A PREROUTING -i wan0 -p tcp -m length --length 0:64 -j MARK --set-xmark 10
iptables -t mangle -A PREROUTING -i wan0 -p udp -j MARK --set-xmark 10
iptables -t mangle -A PREROUTING -i wan0 -p tcp -m tcp --dport 8080 -j MARK --set-xmark 30
iptables -t mangle -A PREROUTING -i wan0 -p tcp -m tcp --sport 8080 -j MARK --set-xmark 30

tc qdisc del dev wan0 root
tc qdisc add dev wan0 root handle 1: htb default 20
tc class add dev wan0 parent 1: classid 1:1 htb rate 24500kbit
tc class add dev wan0 parent 1:1 classid 1:10 htb rate 10000kbit ceil 24500kbit prio 1
tc class add dev wan0 parent 1:1 classid 1:20 htb rate 10000kbit ceil 24500kbit prio 2
tc class add dev wan0 parent 1:1 classid 1:30 htb rate 4000kbit ceil 24500kbit prio 3
tc filter add dev wan0 parent 1:1 prio 0 protocol ip handle 10 fw flowid 1:10
tc filter add dev wan0 parent 1:1 prio 0 protocol ip handle 20 fw flowid 1:20
tc filter add dev wan0 parent 1:1 prio 0 protocol ip handle 30 fw flowid 1:30

Any ideas? Also if there's an easier way than trying to do it like this, please say so.

Offline

Board footer

Powered by FluxBB