From: "Nataniel Klug" Date: Wed, 11 Jan 2006 10:06:33 +0000 Subject: Re: [LARTC] control p2p upload bandwidth rate Message-Id: <002d01c61696$b39af420$0e001eac@NATANIEL> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============0334451421==" List-Id: References: <43AAE878.10404@phreaker.net> In-Reply-To: <43AAE878.10404@phreaker.net> To: lartc@vger.kernel.org This is a multi-part message in MIME format. --===============0334451421== Content-Type: multipart/alternative; boundary="----=_NextPart_000_002A_01C61685.EFA42010" This is a multi-part message in MIME format. ------=_NextPart_000_002A_01C61685.EFA42010 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Jody, My question is not about P2P filters. This is working fine at my gateway = box. My question concerns to my autentication gateway, where I use PPPoE = to autenticante my LAN clients at a Radius server into my DMZ. This PPPoE server, when I have a new conection, make some rules using = IPTABLES and CBQ/HTB to control my clients internet speed. The script I = use when a client conects is this: =3D=3D=3D /etc/ppp/ip-up =3D=3D=3D #! /bin/bash IPT=3D"/usr/local/sbin/iptables" interface=3D$1 remoteIP=3D$5 download=3D`grep Download /var/run/radattr.$interface | awk '{ print $2; = }'` upload=3D`grep Upload /var/run/radattr.$interface | awk '{ print $2; = }'` cliente=3D`grep Cliente /var/run/radattr.$interface | awk '{ print $2; = }'` contamark=3D`echo $interface | cut -c 4-99` mark=3D`expr $contamark + 500` echo "$download" > /tmp/$interface.download echo "$upload" > /tmp/$interface.upload echo "$cliente" > /tmp/$interface.cliente #if [ $cliente =3D=3D "cliente" ] #then #$IPT -I FORWARD -d $remoteIP -p tcp --dport 1:1024 -j DROP #$IPT -I FORWARD -d $remoteIP -p tcp --dport 6000:9000 -j DROP #fi /sbin/tc qdisc add dev $interface root handle 1 cbq bandwidth 10Mbit = avpkt 1000 cell 8 /sbin/tc class add dev $interface parent 1: classid 1:$mark cbq = bandwidth 10Mbit rate "$download"Kbit weight `expr $download / 10`Kbit = prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded /sbin/tc qdisc add dev $interface parent 1:$mark handle $mark sfq = perturb 10 /sbin/tc filter add dev $interface parent 1:0 protocol ip prio 200 = handle $mark fw classid 1:$mark $IPT -t mangle -A POSTROUTING -d $remoteIP -j MARK --set-mark $mark /sbin/tc qdisc add dev eth0 root handle 1 cbq bandwidth 10Mbit avpkt = 1000 cell 8 /sbin/tc class add dev eth0 parent 1: classid 1:$mark cbq bandwidth = 10Mbit rate "$upload"Kbit weight `expr $upload / 10`Kbit prio 5 allot = 1514 cell 8 maxburst 20 avpkt 1000 bounded /sbin/tc qdisc add dev eth0 parent 1:$mark handle $mark sfq perturb 10 /sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 200 handle = $mark fw classid 1:$mark $IPT -t mangle -A FORWARD -s $remoteIP -j MARK --set-mark $mark echo "PPP started at $(date): interface =3D $interface Remote IP =3D $remoteIP download =3D $download upload =3D $upload mark =3D $mark " >/tmp/$interface =3D=3D=3D END =3D=3D=3D My doubt is, what you said is that only one package in a mark will me = matched without that other comands, so, the lines I have put in red are = correct? Today it is working fine, but I have never made a test longer = than 20 or 30 minutes... Att, Nataniel Klug ----- Original Message -----=20 From: Jody Shumaker=20 To: Nataniel Klug=20 Cc: lartc@mailman.ds9a.nl=20 Sent: Wednesday, January 11, 2006 3:11 AM Subject: Re: [LARTC] control p2p upload bandwidth rate #accepts the packet if it has a mark besides the default 0 and = prevents the saved mark from being changed=20 iptables -t mangle -A PREROUTING -p tcp -m mark ! --mark 0 -j ACCEPT That section after the restore-mark rule will cause any saved marks to = skip the rest of the chain. This results in only the first packets of a = tcp connection having to hit their individual --set-mark rule. If you = do have concerns about cpu usage or some such, I'd suggest trying = trying out the ipp2p match module instead of the more generic l7match = module. It's more specific to p2p and tends to be much faster than = doing regular expressions.=20 On 1/10/06, Nataniel Klug wrote: I have a script that makes connections for every user with his auth. = So, in this script, I have two mark tags. Can I use this tip you give to = ro0ot? My doubt is if I use this every time some user log it will be all = executed again, it will not make me trouble? I'm not sure exactly what you mean by this. If my above explanation = doesn't apply, could you possibly explain or give an example? - Jody ------=_NextPart_000_002A_01C61685.EFA42010 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Jody,
 
My question is not about P2P filters. = This is=20 working fine at my gateway box. My question concerns to my autentication = gateway, where I use PPPoE to autenticante my LAN clients at a Radius = server=20 into my DMZ.
 
This PPPoE server, when I have a new = conection,=20 make some rules using IPTABLES and CBQ/HTB to control my clients = internet speed.=20 The script I use when a client conects is this:
 
=3D=3D=3D /etc/ppp/ip-up=20 =3D=3D=3D
#!=20 /bin/bash
IPT=3D"/usr/local/sbin/iptables"
 
interface=3D$1
remoteIP=3D$5
download=3D`grep Download=20 /var/run/radattr.$interface | awk '{ print $2; }'`
upload=3D`grep = Upload =20 /var/run/radattr.$interface | awk '{ print $2; }'`
cliente=3D`grep = Cliente=20 /var/run/radattr.$interface | awk '{ print $2; }'`
contamark=3D`echo = $interface=20 | cut -c 4-99`
mark=3D`expr $contamark + 500`
 
echo "$download" >=20 /tmp/$interface.download
echo "$upload" > = /tmp/$interface.upload
echo=20 "$cliente" > /tmp/$interface.cliente
 

#if [ $cliente =3D=3D = "cliente"=20 ]
#then
#$IPT -I FORWARD -d $remoteIP -p tcp --dport 1:1024 -j=20 DROP
#$IPT -I FORWARD -d $remoteIP -p tcp --dport 6000:9000 -j=20 DROP
#fi
 

/sbin/tc qdisc add = dev $interface=20 root handle 1 cbq bandwidth 10Mbit avpkt 1000 cell 8
/sbin/tc class = add dev=20 $interface parent 1: classid 1:$mark cbq bandwidth 10Mbit rate = "$download"Kbit=20 weight `expr $download / 10`Kbit prio 5 allot 1514 cell 8 maxburst 20 = avpkt 1000=20 bounded
/sbin/tc qdisc add dev $interface parent 1:$mark handle $mark = sfq=20 perturb 10
/sbin/tc filter add dev $interface parent 1:0 protocol ip = prio 200=20 handle $mark fw classid 1:$mark
$IPT -t mangle = -A=20 POSTROUTING -d $remoteIP -j MARK --set-mark = $mark
 

/sbin/tc qdisc add = dev eth0 root=20 handle 1 cbq bandwidth 10Mbit avpkt 1000 cell 8
/sbin/tc class add = dev eth0=20 parent 1: classid 1:$mark cbq bandwidth 10Mbit rate "$upload"Kbit weight = `expr=20 $upload / 10`Kbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000=20 bounded
/sbin/tc qdisc add dev eth0 parent 1:$mark handle $mark  = sfq=20 perturb 10
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio = 200=20 handle $mark fw classid 1:$mark
$IPT -t mangle = -A FORWARD=20 -s $remoteIP -j MARK --set-mark $mark
 

echo "PPP=20 started at $(date):
interface =3D $interface
Remote IP =3D=20 $remoteIP
download =3D $download
upload =3D $upload
mark =3D = $mark
"=20 >/tmp/$interface

=3D=3D=3D END = =3D=3D=3D
 
My doubt is, what you said is that = only one=20 package in a mark will me matched without that other comands, so, the = lines I=20 have put in red are correct? Today it is working fine, but I have never = made a=20 test longer than 20 or 30 minutes...
 
Att,
 
Nataniel Klug
----- Original = Message -----=20
From: Jody=20 Shumaker
To: = Nataniel Klug =
Cc: = lartc@mailman.ds9a.nl =
Sent: = Wednesday,=20 January 11, 2006 3:11 AM
Subject: = Re: [LARTC]=20 control p2p upload bandwidth rate

#accepts the=20 packet if it has a mark besides the default 0 and prevents the saved = mark from=20 being changed
iptables -t mangle -A PREROUTING -p tcp -m mark ! = --mark 0=20 -j ACCEPT

That section after the restore-mark rule will cause = any saved=20 marks to skip the rest of the chain.  This results in only the = first=20 packets of a tcp connection having to hit their individual --set-mark=20 rule.  If you do have concerns about cpu usage or some = such,  I'd=20 suggest trying trying out the ipp2p match module instead of the more = generic=20 l7match module.  It's more specific to p2p and tends to be much = faster=20 than doing regular expressions.

On = 1/10/06, Nataniel Klug <nata@cnett.com.br>=20 wrote:
I have a script that makes = connections for=20 every user with his auth. So, in this script, I have two mark tags. = Can I=20 use this tip you give to ro0ot? My doubt is if I use this every time = some=20 user log it will be all executed again, it will not make me=20 trouble?

I'm not sure exactly what you = mean by this.=20 If my above explanation doesn't apply, could you possibly explain or = give an=20 example?

-=20 Jody

------=_NextPart_000_002A_01C61685.EFA42010-- --===============0334451421== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc --===============0334451421==--