Link to home
Start Free TrialLog in
Avatar of drkbg
drkbg

asked on

htb shape upload dsl

hi! :)

first of all my network looks something like this. there is a switch on wich are connected dsl bridge modem, server and client boxes. the server machine act as dns, web server and router/firewall. It's a slack install. I figured out how to shape the incoming traffic for clients (the download from internet) but im still confused hwo to do it with outgoing traffic. the problem is that i have only one real IP which in fact changes every 24 hours and i have to use MASQUARADING. i mean that i wan every clinet mahcine to have X kb/s upload and if there is free bandwith to get the whole bandwith. I am using htb to shape incoming traffic from internet. any suggestions how to shape the uploads to internet?
Avatar of Ustas
Ustas

#!/bin/bash
/sbin/tc qdisc del dev eth0 root 2>/dev/null

        AQ="/sbin/tc qdisc add"
        AC="/sbin/tc class add"
        AF="/sbin/tc filter add"

###########################################################$AQ dev eth0 root handle 10: cbq bandwidth 100Mbit avpkt 100 cell 8
##For a 100Mbps nic

$AC dev eth1 parent 10:0 classid 10:1 cbq \
        allot 1514 cell 8 maxburst 20 avpkt 1000 prio 2 \
        bandwidth 100Mbit rate 100Mbit weight 10Mbit

############################################################## DSL upload

##Total Upload (fast) ;)) Specify your max upload here
$AC dev eth1 parent 10:0 classid 10:1100 cbq \
        allot 1514 cell 8 maxburst 20 avpkt 1100 prio 4 \
        bandwidth 512Kbit rate 512Kbit weight 52Kbit  bounded

$AQ dev eth1 parent 10:1100 handle 100: cbq bandwidth 100Mbit avpkt 100 cell 8

##Child leaf node for DSL upstream. Define various speed #classes here
$AC dev eth1 parent 100:0 classid 100:1 cbq \
        allot 1514 cell 8 maxburst 20 avpkt 1100 prio 5 \
        bandwidth 100Kbit rate 100Kbit weight 10Kbit bounded
$AC dev eth1 parent 100:0 classid 100:2 cbq \
        allot 1514 cell 8 maxburst 20 avpkt 1100 prio 5 \
        bandwidth 200Kbit rate 200Kbit weight 20Kbit bounded
$AC dev eth1 parent 100:0 classid 100:3 cbq \
        allot 1514 cell 8 maxburst 20 avpkt 1100 prio 5 \
        bandwidth 100kbit rate 160Kbit weight 16Kbit bounded


##SFQ to all.. Use this queueing disc.. Easier on CPU ;)
$AQ dev eth1 parent 100:1 handle 1001:  sfq quantum 100Kbit
$AQ dev eth1 parent 100:2 handle 1002:  sfq quantum 200Kbit
$AQ dev eth1 parent 100:3 handle 1003:  sfq quantum 160Kbit

##Start Filters - Place ur custom rules for
# particular machines.

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

### Put all ADSL upload to 10:1100 (With any ADSL subnets)
$AF dev eth1 parent 100:0 protocol ip prio 1 u32 match \
ip src 192.168.0.1/32 flowid 100:2
## Here you are giving machine 192.168.0.1 upload of class 100:2 that is 200Kbps

Well work your way from here.. This is a part of my script that handles hundreds of rules. This is in fact part of traffic shaping for ISP's outgoing traffic
oops.. change eth1 to eth0..
Avatar of drkbg

ASKER

but does this work with masquerading?
somehow this shapes the traffic to the server only not to the internet... i think that packets not for the server but for the internet are masquearaded. and all internal IPs get the masquearading ip and and that stage they cannot be shaped :(. i'm not really sure that what im'm talking is the full truth, but it's something like this.
you can only shape the upload.. That is out from the server. What your interest is to make the filters right. That is if you specify that the filters have src from your internal network, things should work out right. Did you try the sfq ??
drkbg:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Avatar of drkbg

ASKER

i got it... you need hust to shape on ppp0... not ethX
why did you give points to moderator????
Avatar of drkbg

ASKER

cause noone was close to the answer...and i needed to close this topic...
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial