My needs is limiting the outbound traffic of an smtp mail server. It is connected to a gateway via 100Mbit ethernet. I want limits its outbound traffic to max 3 Mbit. I have read lot of docs and tried various script without great results. Any simplest solutions? TIA. Regards, B.
http://members.cox.net/laitcg/slack1.html Go to the bottom about throttling the bandwidth of a single host. If you just want the daemon itself to be throttled (IE, just the mail traffic) someone else with a bigger clue than me will have to help you. -Michael> -----Original Message----- > From: lartc-bounces@mailman.ds9a.nl [mailto:lartc-bounces@mailman.ds9a.nl] > On Behalf Of Barbara M. > Sent: Monday, July 11, 2005 1:41 PM > To: lartc@mailman.ds9a.nl > Subject: [LARTC] Simple traffic shaping > > > My needs is limiting the outbound traffic of an smtp mail server. > It is connected to a gateway via 100Mbit ethernet. I want limits its > outbound traffic to max 3 Mbit. > > I have read lot of docs and tried various script without great results. > > Any simplest solutions? > > TIA. > Regards, B. > > > > _______________________________________________ > LARTC mailing list > LARTC@mailman.ds9a.nl > http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
On Mon, 11 Jul 2005, ICI Support wrote:> http://members.cox.net/laitcg/slack1.html > > Go to the bottom about throttling the bandwidth of a single host. > > If you just want the daemon itself to be throttled (IE, just the mail > traffic) someone else with a bigger clue than me will have to help you. > > -MichaelThanks for replay. As you suggested I tried to modify the script for my needs. I finally have this: -------------------------------------------------------- #!/bin/bash # Slow down one ip address on internal network # If you changed anything and want to reload the script, execute # /etc/rc.d/rc.throttle stop # to clean up your existing configuration. # Place IP address to be throttled in TIP TIP="192.168.1.25" # Place device to internal network here DEV="eth0" if [ "$1" = "stop" ]; then echo "Removing Throttle" tc qdisc del dev $DEV root else # assume $1 = start: echo "Throttling $TIP" tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 100mbit tc class add dev $DEV parent 1: classid 1:1 cbq rate 2512kbit allot 1500 prio 5 bounded isolated tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip src $TIP flowid 1:1 tc qdisc add dev $DEV parent 1:1 sfq perturb 10 fi -------------------------------------------------------- Have done some test using scp from other internal box. Before starting the tc rules I have UP/DL to the smtp server at 8-10MB/s After activation of rules I have DL to about 270KB/s (as aspected), UP to 550-600KB. ??? Why UPload is affected? Any optimization? TIA, Barbara
Barbara M. wrote:> > My needs is limiting the outbound traffic of an smtp mail server. > It is connected to a gateway via 100Mbit ethernet. I want limits its > outbound traffic to max 3 Mbit. > > I have read lot of docs and tried various script without great results. > > Any simplest solutions? > > TIA. > Regards, B. > > > > _______________________________________________ > LARTC mailing list > LARTC@mailman.ds9a.nl > http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc >You should be able to mark all the smtp packets with iptables and then shape them with tc. There are examples of marking and the shaping commands in the docs. For reference, this is how i mark and shape ftp traffic. You will need something similar. I mark ftp traffic by port and then shape. iptables -t mangle -N MYSHAPER-OUT iptables -t mangle -I OUTPUT -o eth0 -j MYSHAPER-OUT iptables -t mangle -A MYSHAPER-OUT -m mark --mark 0 -j MARK --set-mark 20 iptables -t mangle -A MYSHAPER-OUT -p tcp --sport 59999 -j MARK --set-mark 26 iptables -t mangle -A MYSHAPER-OUT -p tcp --sport 50000:51000 -j MARK --set-mark 26 iptables -t mangle -A MYSHAPER-OUT -p tcp -m length --length :64 -j MARK --set-mark 20 # clear it tc qdisc del dev eth0 root #add the root qdisk tc qdisc add dev eth0 root handle 1: htb default 20 #add main rate limit class tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit #add leaf classes tc class add dev eth0 parent 1:1 classid 1:26 htb rate 40kbps tc class add dev eth0 parent 1:1 classid 1:20 htb rate 100mbit #filter traffic into classes tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 20 fw flowid 1:20 tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 26 fw flowid 1:26 Mark
"Barbara M." wrote:> > My needs is limiting the outbound traffic of an smtp mail server. > It is connected to a gateway via 100Mbit ethernet. I want limits its > outbound traffic to max 3 Mbit. > > I have read lot of docs and tried various script without great results. > > Any simplest solutions? > > TIA. > Regards, B.HTB: tc qdisc add dev $DEV root handle 1: htb default 20 tc class add dev $DEV parent 1: classid 1:1 htb rate 3000kbit burst 6k tc class add dev $DEV parent 1:1 classid 1:20 htb rate 3000kbit \ burst 6k quantum 1500 prio 1 tc filter add dev $DEV parent 1: protocol ip prio 5 u32 \ match ip sport 25 0xffff flowid 1:20 TRICKLE: http://monkey.org/~marius/trickle But I doubt the above will suit you because you don''t tell us anything else about the traffic on your mail server. -- gypsy
On Mon, 11 Jul 2005, gypsy wrote:>> My needs is limiting the outbound traffic of an smtp mail server. >> It is connected to a gateway via 100Mbit ethernet. I want limits its >> outbound traffic to max 3 Mbit.> HTB: > tc qdisc add dev $DEV root handle 1: htb default 20Create the root and set the default for traffic to filter/class "20". Needed (filter/class "20")?> tc class add dev $DEV parent 1: classid 1:1 htb rate 3000kbit burst 6kCreate the class 1:1, set maximum rate to 3mbit. Can be useful increase the 6k burst?> tc class add dev $DEV parent 1:1 classid 1:20 htb rate 3000kbit \ > burst 6k quantum 1500 prio 1??? what do the "quantum 1500" part?> tc filter add dev $DEV parent 1: protocol ip prio 5 u32 \ > match ip sport 25 0xffff flowid 1:20Create a filter for smtp traffic? Why "sport 25"? I am interested in outgoing traffic. This box receive the outgoing mails from other internal servers and do the delivery. No other activity/traff. So can be useful that it receive traffic from local server at full speed, but delivery it at limited rate (the problem is mailing list users that sometime distribuite big mail (0.5-2 MB) to 1.000-3.000 subscribers causing peak that ... :-( Really I am thinking to use it to shape the total traffic from a server with no differentiation on services (so I can use it in mail or httpd server ...). Regards, B.