Skip to contentSkip to conversation

HTB problem...

LARTC Cow 3 participants 6 messages Sep 6, 2004 – Sep 7, 2004

lore
Share & tools
lore

Cow

author
#0 lore raw

Hi folks.

Let's say I would like to make some bandwidth control on my network using HTB. I have 2 clients:

PC1: 192.168.100.2
PC2: 192.168.100.3

Server:
192.168.100.1
This has 2 NIC's eth1 is local and eth2 is connected to the internet.

It could be nice to have a script, where you could specify, how much bandwidth you want for a specific host on a network, like, PC1 has 10/100 MBit network, but only has 256/128, when surfing the net. PC2 has the same network ofc, but 768/384 when surfing/downloading assuming the shared connection is 1024/512.

I am currently running wondershaper1.1a which works prefectly, but i wish, it could be more specific.
Could also be nice, if it would be someway possible to check on the clients IP or MAC address to verify, if it's "really them". Like it's only PC1 and PC2 who have access to the server in the 192.168.*.* segment. Hope i make myself clear.

My server runs redhat 9 in cmd mode/no GUI.
Iptables installed script, as firewall.

I think a script as i described, could be very complex to write, therefore i ask, whoever is here, for help.
Thank you all in advance.

Regards
Rune Johannesen
Denmark

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

#1 lore raw

Dnia poniedzia³ek 06 wrzesieñ 2004 23:56, Cow napisa³:

Quoted 4 lines

Hi folks.

Let's say I would like to make some bandwidth control on my network using HTB. I have 2 clients:

[...]

Quoted 3 lines

I think a script as i described, could be very complex to write, therefore i ask, whoever is here, for help.
Thank you all in advance.

Hello all, my first post here, maybe even I will help someone;)

I assume that you want somethink like:
data from server to LAN (PC1,PC2) unshaped (full 100mbit) data from Internet to LAN shaped

Then all you need to do is make classes with source 192.168.0.1 and destination 192.168.0.2(3) and 100mbit rate and then make classes with destination 192.168.0.2(3) with download rate. I believe that you understand what I am thinkig of.

Or you can use iptables and mark traffic going from server to LAN, and other mark for traffic in FORWARD chain. (iptables -t mangle -A FORWARD -j MARK --set-mark SOME_MARK)
When using iptables you will be able to shape upload speed, just mark traffic in forward going from PC1/2 with output interface eth2 (-o eth2) - it will be hosts upload.

I won't write you full script, make it yourself, visit LARTC and firstly try "htb.init" for simple class creation. Good fun!

Signature · 7 lines
.: Jakub G³azik (zytek)
.: email:[email protected]
.: JID:[email protected]
.: http://www.misiaj.sie.pl [obsolete]
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
author
#2 lore raw
In reply to Cow

I've tryed to make a script, some of you, who thinks it looks ok?

DEV=eth2
DOWNLINK24
UPLINKQ2

DOWN1v8
UP184

DOWN2%6
UP28

tc qdisc add dev $DEV root handle 1: htb default 20

tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
burst 6k prio 1
tc class add dev $DEV parent 1:1 classid 1:20 htb rate ${UP1}kbit \
burst 6k prio 2
tc class add dev $DEV parent 1:1 classid 1:30 htb rate ${UP2}kbit \
burst 6k prio 2

tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10

tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \

           match ip src 192.168.0.2 flowid 1:20
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \
           match ip src 192.168.0.3 flowid 1:30

Not tested yet...
If it works, feel free to letting me know, how to make something like this, just for download rate.
If it doesn't work, please let me know, what you think is wrong.

- Rune Johannesen

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

author
#4 lore raw
In reply to Cow
Quoted 6 lines

by zytek
Hello all, my first post here, maybe even I will help someone;)

I assume that you want somethink like:
data from server to LAN (PC1,PC2) unshaped (full 100mbit) data from Internet to LAN shaped

Correct.

Quoted 3 lines

Then all you need to do is make classes with source 192.168.0.1 and destination 192.168.0.2(3) and 100mbit rate and then make classes with destination 192.168.0.2(3) with download rate. I believe that you

understand

Quoted 1 line

what I am thinkig of.

I do, but could you write an example please, so i have something to make it from? :-)

Quoted 1 line

Or you can use iptables and mark traffic going from server to LAN, and

other

Quoted 1 line

mark for traffic in FORWARD chain. (iptables -t mangle -A FORWARD -j

MARK

Quoted 2 lines

--set-mark SOME_MARK)
When using iptables you will be able to shape upload speed, just mark

traffic

Quoted 1 line

in forward going from PC1/2 with output interface eth2 (-o eth2) - it

will be

Quoted 1 line

hosts upload.

Again, an example would be nice.. i have no idea on how to use MARK command with iptables, even i know a great deal about iptables in general.

Quoted 1 line

I won't write you full script, make it yourself, visit LARTC and

firstly try

Quoted 1 line

"htb.init" for simple class creation. Good fun!

Fair enough, i wouldn't exspect anyone to write a full script for me, but i would exspect someone to make me an example for instance, how i can shape PC1's download/upload rate to 256/128 KBit, so i atleast have something to help me going.

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

#5 lore raw
In reply to Cow

Am Tuesday 07 September 2004 23:18 schrieb Cow:

Quoted 6 lines

zytec: (?)

Quoted 3 lines

I assume that you want somethink like:
data from server to LAN (PC1,PC2) unshaped (full 100mbit) data from Internet to LAN shaped

Correct.

Not really an example, but you may have a look at my script [1].

It solves the 100Mbit LAN vs internet traffic by using a class setup which looks like [2], which reminds me that I did a modification to wondershaper once [3] that does the same. I think this modification was reported to work, however I haven't tested it nor do I support it. Maybe it serves as an example...

I'm using a fat HTB class which knows the true interface bandwidth (100MBit isn't actually right, you should measure what rates you really get). Then there's a child class for the internet traffic and one for the actual LAN traffic. If HTB works correctly, this way you get full speed for LAN-only transfers, without letting them interfere with the internet traffic.

The script [1] is the one I'm (more or less) actively working on; it doesn't support custom rates per user yet, but that's something that'll be added for sure in one of the next releases.

HTH
Andreas

[1] http://www.metamorpher.de/fairnat/
[2] http://www.metamorpher.de/files/wshaper-over-lan.png
[3] http://www.metamorpher.de/files/wshaper-over-lan.htb
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/