Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Gáspár Lajos" <swifty@freemail.hu>
To: Marco Coda <marco.coda7@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: [half_OT]Traffic shaping with tc and iptables
Date: Thu, 08 Sep 2011 11:14:11 +0200	[thread overview]
Message-ID: <4E688763.2060209@freemail.hu> (raw)
In-Reply-To: <CAGRr-qktvGncegdp+7X7Xb7Q9L0Q+FAn3+gPHGy+XJhDRtkQYg@mail.gmail.com>

Hi!

> For example, here we have 2 Mb in upload. I want to leave to the server 1 Mb max
>
>

> Here there is the script I ran:
> ############################################################################
> # path of iptables
> IPTABLES=/sbin/iptables
> # ethernet interface that I want to limit
> nic=eth0
> # Port I want to limit
> port=25
> # Maximum upload limit...
> upload=10
> # ...and relative unit
> unit=kbit
Or: upload='1Mbit'
> # Maximum LAN speed (we have 100Mb switch so..)
> maxspeed=100Mbit
I would set: bandwidth='2Mbit'
> # weight of the limit...
> weight=1
Not really needed...
> # ...and relative unit
> unit2=kbit
>
> tc qdisc del dev $nic root&&  iptables -t mangle -F
> $IPTABLES -t mangle -A OUTPUT -p tcp --sport $port -j MARK --set-mark 1
$IPTABLES -t mangle -A OUTPUT -p tcp -o $nic --sport $port -j MARK 
--set-mark 1
> tc qdisc add dev $nic root handle 10: cbq bandwidth $maxspeed avpkt 1000 mpu 64
tc qdisc add dev $nic root handle 1:0 cbq bandwidth $bandwidth avpkt 
1000 mpu 64
> tc class add dev $nic parent 10:0 classid 10:1 cbq rate $upload$unit
> weight $weight$unit2 allot 1514 prio 1 avpkt 1000 bounded
tc class add dev $nic parent 1:0 classid 1:1 cbq rate $upload allot 1514 
prio 1 avpkt 1000 bounded isolated
# Check if you need isolated.... man tc-cbq

> tc filter add dev $nic parent 10:0 protocol ip handle 1 fw flowid 10:1
tc filter add dev $nic parent 1:0 ip handle fw flowid 1:1


Swifty


  reply	other threads:[~2011-09-08  9:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08  7:44 [half_OT]Traffic shaping with tc and iptables Marco Coda
2011-09-08  9:14 ` Gáspár Lajos [this message]
2011-09-08  9:17   ` Gáspár Lajos
2011-09-08 10:54   ` Marco Coda
2011-09-08 11:20     ` Gáspár Lajos
2011-09-08 12:10       ` Marco Coda
2011-09-08 12:22         ` Gáspár Lajos
2011-09-08 14:00           ` Marco Coda
2011-09-08 14:52             ` Gáspár Lajos
2011-09-08 14:57             ` Nikolay Kichukov
2011-09-08 15:38               ` Marco Coda
2011-09-08 12:40         ` Nikolay Kichukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E688763.2060209@freemail.hu \
    --to=swifty@freemail.hu \
    --cc=marco.coda7@gmail.com \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox