From mboxrd@z Thu Jan 1 00:00:00 1970 From: nix4me Date: Tue, 12 Jul 2005 00:53:38 +0000 Subject: Re: [LARTC] Simple traffic shaping Message-Id: <42D31492.1010206@cfl.rr.com> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lartc@vger.kernel.org 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 _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc