Skip to contentSkip to conversation

HTB services & IP's

LARTC Vlad Mihai 1 participant 1 message Aug 19, 2003

lore
Share & tools
lore

Vlad Mihai

author
#0 lore raw

Hello,

I live in Romania where Internet is quite expensive for kids like me.
We have managed to buy a 8/128 kbit (kilo bit) not kbps (kilo bytes).
It means that my ISP guarantees that the traffic won’t fall below 8kbit and can achieve 128kbit. I have a "SlackWare" Linux box that is used for NAT.
There are about 10 clients that will share the bandwidth.

I am very new to HTB and tc, so the answer for this question is a piece of cake for u ☺ I read an excellent article here: http://lartc.org/howto/lartc.cookbook.fullnat.intro.html

That script is somehow "service-focused", meaning that it filters the traffic based on services and ports. Mine is "IP-focused", meaning that it filters the traffic based on IP’s in my LAN.

What I want is to "combine" these to types of scripts and have equal sharing among my clients and also prioritizing the traffic, as the article explains, based on services. What I had in mind so far was to create some leaf classes for each of my 8 clients, (I split the band in 8 pieces and after that I prioritize services on each of these pieces).
But this would make the script huge.

I don’t know what to do… How can I mark (filter) the packets (with IPTables mangle) based on IP’s but also on services they need?

Thanking you in advance,
Vlad Mihai

P.S.
BTW, I observed that the filtering works only for downloads, and is ignored for uploads....

Here is my script:

#!/bin/sh

LAN_IFACE=eth0
TC=/sbin/tc
FILTER="$TC filter add dev $LAN_IFACE protocol ip parent 1:0 prio 1 u32 match ip"

$TC qdisc del dev $LAN_IFACE root >/dev/null 2>&1 # Delete previous root qdisc

$TC qdisc add dev $LAN_IFACE root handle 1: htb default 30 # root qdisc
$TC class add dev $LAN_IFACE parent 1: classid 1:1 htb rate 128kbit ceil 128kbit burst 30k # root class

$TC class add dev $LAN_IFACE parent 1:1 classid 1:30 htb rate 1kbit ceil 128kbit burst 30k # default class
$TC qdisc add dev $LAN_IFACE parent 1:30 handle 30: sfq perturb 10 # dafault class queuing discipline

$TC class add dev $LAN_IFACE parent 1:1 classid 1:11 htb rate 8kbit ceil 128kbit burst 30k # mihai.tarnita.net
$FILTER dst 192.168.0.121 flowid 1:11
$TC qdisc add dev $LAN_IFACE parent 1:11 handle 11: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:12 htb rate 8kbit ceil 128kbit burst 30k # horea.tarnita.net
$FILTER dst 192.168.0.122 flowid 1:12
$TC qdisc add dev $LAN_IFACE parent 1:12 handle 12: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:13 htb rate 8kbit ceil 128kbit burst 30k # sergiu.tarnita.net
$FILTER dst 192.168.0.123 flowid 1:13
$TC qdisc add dev $LAN_IFACE parent 1:13 handle 13: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:14 htb rate 8kbit ceil 128kbit burst 30k # damian.tarnita.net
$FILTER dst 192.168.0.124 flowid 1:14
$TC qdisc add dev $LAN_IFACE parent 1:14 handle 14: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:15 htb rate 8kbit ceil 128kbit burst 30k # victor.tarnita.net
$FILTER dst 192.168.0.141 flowid 1:15
$TC qdisc add dev $LAN_IFACE parent 1:15 handle 15: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:16 htb rate 8kbit ceil 128kbit burst 30k # liana.tarnita.net
$FILTER dst 192.168.0.144 flowid 1:16
$TC qdisc add dev $LAN_IFACE parent 1:16 handle 16: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:17 htb rate 8kbit ceil 128kbit burst 30k # adi.tarnita.net
$FILTER dst 192.168.0.145 flowid 1:17
$TC qdisc add dev $LAN_IFACE parent 1:17 handle 17: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:18 htb rate 8kbit ceil 128kbit burst 30k # kiowa.tarnita.net
$FILTER dst 192.168.0.161 flowid 1:18
$TC qdisc add dev $LAN_IFACE parent 1:18 handle 18: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:19 htb rate 8kbit ceil 128kbit burst 30k # boby.tarnita.net
$FILTER dst 192.168.0.181 flowid 1:19
$TC qdisc add dev $LAN_IFACE parent 1:19 handle 19: sfq perturb 10

$TC class add dev $LAN_IFACE parent 1:1 classid 1:20 htb rate 8kbit ceil 128kbit burst 30k # delia.tarnita.net
$FILTER dst 192.168.0.185 flowid 1:20
$TC qdisc add dev $LAN_IFACE parent 1:20 handle 20: sfq perturb 10

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/