Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
help traffic shaping
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
t0mcat
Tux's lil' helper
Tux's lil' helper


Joined: 12 Feb 2004
Posts: 111
Location: Catania, Italy

PostPosted: Wed Apr 13, 2005 1:23 am    Post subject: help traffic shaping Reply with quote

sto cercando di sistemare il mio web/file/mail server con QoS per evitare che ogni tanto la mia modesta alice non si impalli completamente a causa di troppi kb/s richiesti in uscita.

ho seguito diverse guide e diversi howto ed e' stato facile riuscire a limitare il traffico della porta 80 (che nel mio caso e' quella da cui passa piu' traffico) ma non sono riuscito a risolvere un problema: limitare il traffico solo quando e' diretto verso la wan e non verso la lan.

ecco lo script:

Code:

#!/bin/bash
########################

# network device
DEVICE="eth0"

# tc executable full path
TC_EXEC="/sbin/tc"

# lan max upload speed
LANMAXSPEED="100000"
LIMIT="120"

########################

if [ "$1" = "--start" ]
then

        ${TC_EXEC} qdisc add dev $DEVICE root handle 1: htb default 10
        ${TC_EXEC} class add dev $DEVICE parent 1: classid 1:1 htb rate ${LANMAXSPEED}kbit
        ${TC_EXEC} class add dev $DEVICE parent 1:1 classid 1:10 htb rate ${LANMAXSPEED}kbit
        ${TC_EXEC} class add dev $DEVICE parent 1:1 classid 1:20 htb rate ${LIMIT}kbit
        ${TC_EXEC} filter add dev $DEVICE protocol ip parent 1:0 prio 1 u32 match ip sport 80 0xffff flowid 1:20

else if [ "$1" = "--stop" ]
then

        tc qdisc del dev $DEVICE root

else
        echo "Usage: trafficshaper { COMMAND }"
        echo "Command: { --start | --stop }"
fi
fi


ho provato a fare qualcosa di piu' complesso ma il risultato e' stato che non limitava un bel niente:

Code:

#!/bin/bash
########################

# network device
DEVICE="eth0"

# tc executable full path
TC_EXEC="/sbin/tc"

# lan max upload speed
LANMAXSPEED="100000"
# lan guaranteed upload speed
LANGUARSPEED="50000"

# wan max upload speed
WANMAXSPEED="256"
# wan guaranteed upload speed
WANGUARSPEED="128"

########################

if [ "$1" = "--start" ]
then

         ${TC_EXEC} qdisc add dev $DEVICE root handle 1: htb default 10

         ${TC_EXEC} class add dev $DEVICE parent 1:  classid 1:1  htb rate ${LANMAXSPEED}kbit
         ${TC_EXEC} class add dev $DEVICE parent 1:1 classid 1:10 htb rate ${LANGUARSPEED}kbit ceil ${LANMAXSPEED}kbit prio 1
         ${TC_EXEC} class add dev $DEVICE parent 1:1 classid 1:20 htb rate ${WANGUARSPEED}kbit ceil ${WANMAXSPEED}kbit prio 2

         ${TC_EXEC} qdisc add dev $DEVICE parent 1:10 handle 10: htb default 101
         ${TC_EXEC} qdisc add dev $DEVICE parent 1:20 handle 20: htb default 201

         ${TC_EXEC} class add dev $DEVICE parent 10:  classid 10:1   htb rate ${LANMAXSPEED}kbit
         ${TC_EXEC} class add dev $DEVICE parent 10:1 classid 10:101 htb rate $[50*$LANGUARSPEED/100]kbit ceil ${LANMAXSPEED}kbit prio 1
         ${TC_EXEC} class add dev $DEVICE parent 10:1 classid 10:102 htb rate $[50*$LANGUARSPEED/100]kbit ceil ${LANMAXSPEED}kbit prio 2

         ${TC_EXEC} class add dev $DEVICE parent 20:  classid 20:1   htb rate ${WANMAXSPEED}kbit
         ${TC_EXEC} class add dev $DEVICE parent 20:1 classid 20:201 htb rate $[50*$WANGUARSPEED]kbit ceil ${WANGUARSPEED}kbit prio 1
         ${TC_EXEC} class add dev $DEVICE parent 20:1 classid 20:202 htb rate $[50*$WANGUARSPEED]kbit ceil ${WANMAXSPEED}kbit prio 2

         ${TC_EXEC} qdisc add dev $DEVICE parent 10:101 handle 101: sfq perturb 10
         ${TC_EXEC} qdisc add dev $DEVICE parent 10:102 handle 102: sfq perturb 10

         ${TC_EXEC} qdisc add dev $DEVICE parent 20:201 handle 201: sfq perturb 10
         ${TC_EXEC} qdisc add dev $DEVICE parent 20:202 handle 202: sfq perturb 10

         ${TC_EXEC} filter add dev $DEVICE parent 1:0 prio 0 protocol ip u32 match ip dst 192.168.1.0/24 flowid 10:101

         ${TC_EXEC} filter add dev $DEVICE parent 1:0 prio 0 protocol ip u32 match ip sport 80 0xffff flowid 20:201

else if [ "$1" = "--stop" ]
then

        tc qdisc del dev $DEVICE root

else
        echo "Usage: trafficshaper { COMMAND }"
        echo "Command: { --start | --stop }"
fi


possibile che non si possa fare un semplice opposto di "match" sulla netmask, da aggiungere al "match" sulla porta?
_________________
il gattaccio
a.k.a etienne
Back to top
View user's profile Send private message
RedNeckCracker
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2003
Posts: 146
Location: Italy

PostPosted: Wed Apr 13, 2005 7:21 am    Post subject: Reply with quote

Io amo le cose semplici, non è che hai pure provato CBQinit ?
_________________
Rage powered

http://www.stud.ntnu.no/~shane/stasj/pics/humor/div/faster_bigger.jpg
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum