Re: [squid-users] Limiting user's bandwidth

From: Andrew Beverley <andy_at_andybev.com>
Date: Tue, 26 Oct 2010 16:46:56 +0100

On Tue, 2010-10-26 at 08:15 -0700, Landy Landy wrote:
> Here's a snip:
>
> #!/bin/bash
> #set -v
> iptables='sudo iptables'
> tc='sudo tc'
> #$iptables -t mangle -F
> #$iptables -t mangle -Z
>
> #####################
> ## Traffic Shaping
> #####################
> ## Parent ID: 1, Associated with iface: eth0 -- External Interface - Internet Side.
> $tc qdisc del dev eth0 root
> $tc qdisc add dev eth0 root handle 1: htb r2q 1
>
> $tc class add dev eth0 parent 1:0 classid 1:1 htb rate 900kbit ceil 945kbit
>
> ## Optimum Wireless
> $iptables -t mangle -A POSTROUTING -s 172.16.254.1 -j MARK --set-mark 1226
> $iptables -t mangle -A POSTROUTING -s 172.16.254.1 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.10 -j MARK --set-mark 1227
> $iptables -t mangle -A POSTROUTING -s 172.16.254.10 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.11 -j MARK --set-mark 1228
> $iptables -t mangle -A POSTROUTING -s 172.16.254.11 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.2 -j MARK --set-mark 1229
> $iptables -t mangle -A POSTROUTING -s 172.16.254.2 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.3 -j MARK --set-mark 1230
> $iptables -t mangle -A POSTROUTING -s 172.16.254.3 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.4 -j MARK --set-mark 1231
> $iptables -t mangle -A POSTROUTING -s 172.16.254.4 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.5 -j MARK --set-mark 1232
> $iptables -t mangle -A POSTROUTING -s 172.16.254.5 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.6 -j MARK --set-mark 1233
> $iptables -t mangle -A POSTROUTING -s 172.16.254.6 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.7 -j MARK --set-mark 1234
> $iptables -t mangle -A POSTROUTING -s 172.16.254.7 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.8 -j MARK --set-mark 1235
> $iptables -t mangle -A POSTROUTING -s 172.16.254.8 -j RETURN
> $iptables -t mangle -A POSTROUTING -s 172.16.254.9 -j MARK --set-mark 1236
> $iptables -t mangle -A POSTROUTING -s 172.16.254.9 -j RETURN
> $tc class add dev eth0 parent 1:528 classid 1:1226 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:529 classid 1:1227 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:530 classid 1:1228 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:531 classid 1:1229 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:532 classid 1:1230 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:533 classid 1:1231 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:534 classid 1:1232 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:535 classid 1:1233 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:536 classid 1:1234 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:537 classid 1:1235 htb rate 141kbit ceil 169kbit prio 4
> $tc class add dev eth0 parent 1:538 classid 1:1236 htb rate 141kbit ceil 169kbit prio 4
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1226 fw classid 1:1226
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1227 fw classid 1:1227
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1228 fw classid 1:1228
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1229 fw classid 1:1229
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1230 fw classid 1:1230
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1231 fw classid 1:1231
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1232 fw classid 1:1232
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1233 fw classid 1:1233
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1234 fw classid 1:1234
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1235 fw classid 1:1235
> $tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1236 fw classid 1:1236
> $tc qdisc add dev eth0 parent 1:1226 handle 1018: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1227 handle 1019: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1228 handle 1020: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1229 handle 1021: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1230 handle 1022: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1231 handle 1023: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1232 handle 1024: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1233 handle 1025: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1234 handle 1026: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1235 handle 1027: sfq perturb 2
> $tc qdisc add dev eth0 parent 1:1236 handle 1028: sfq perturb 2
>
>

I'm not sure that it's causing your problem, but HTB is known to do
strange things if all the bandwidth totals for the classes do not add up
to their parent. Also, is there any particular reason why the root class
has a different rate and ceil?

I would make your parent rate and ceil the same, and then make sure that
the rates of all the leafs add up to that number. The ceil setting for
the leafs can be any amount between the rate of that leaf and the ceil
of the parent.

If you still can't get it working, and as this isn't really a Squid
issue, you might be better off posting to the netfilter-users mailing
list, although I'm happy to help further.

Andy
Received on Tue Oct 26 2010 - 15:47:30 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 27 2010 - 12:00:05 MDT