From: GGounot <g.gounot@laposte.net>
To: lartc@vger.kernel.org
Subject: Re: SFQ + throttling to specific hosts
Date: Wed, 30 Jul 2014 11:31:35 +0000 [thread overview]
Message-ID: <53D8D797.8030108@laposte.net> (raw)
In-Reply-To: <53D81BD2.4000803@thirtyonegifts.com>
Le 30/07/2014 00:10, Roy Kidder a écrit :
> I'm guessing this question has already been asked and answered, but
> I've searched and couldn't find an example for what I'm trying to do.
>
> My Linux firewall has eth0 on the outside, eth1 on the inside. I would
> like to throttle two IPs on my internal network to a predetermined
> bandwidth (say 80K) while using SFQ for everything else. I have the
> SFQ part working with the following:
>
> tc qdisc del dev eth1 root
> tc qdisc add dev eth1 root handle 1: htb default 10
> tc class add dev eth1 parent 1: classid 1:1 htb rate $UPRATE
> tc class add dev eth1 parent 1:1 classid 1:10 htb rate $UPRATE ceil
> $UPRATE mtu 1500
> tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
>
> But I'm not quite sure how to go about rate limiting the two IPs in
> question. From what I've read, CBQ is what I'd use, but can I use that
> along with SFQ? If so, how?
I use this :
# Remove any existing qdisc on eth1
tc qdisc del dev eth1 root
# HTB
tc qdisc add dev eth1 root handle 1:0 htb default 0
# Define max line speed (the maximum speed that the network card is
capable of)
tc class add dev eth1 parent 1:0 classid 1:1 htb rate 1000kbps ceil
1000kbps prio 0
# Define limits
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 80kbps ceil
80kbps prio 0
tc class add dev eth1 parent 1:1 classid 1:11 htb rate 80kbps ceil
80kbps prio 0
# SFQ
tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth1 parent 1:11 handle 11: sfq perturb 10
# You must then redirect the traffic to limit it, you have 2 choices :
# * using a simple "tc" filter and manage redirection with "iptables"
# * or only use "tc"
# using both at the same time may have unexpected behaviour
## 1) Filter traffic using IPTABLES ##
# Filter with FW MARK
tc filter add dev eth1 parent 1:0 prio 0 protocol ip handle 1080 fw
flowid 1:10
tc filter add dev eth1 parent 1:0 prio 0 protocol ip handle 1180 fw
flowid 1:11
# Use iptables' power to match IP/Port Source/Destination, etc.
iptables -t mangle -I FORWARD -d 192.168.0.24 -o eth1 -j MARK
--set-mark 1080
iptables -t mangle -I FORWARD -d 192.168.0.35 -o eth1 -j MARK
--set-mark 1180
# with table FORWARD you match only traffic coming from Internet, not
coming out from firewall
# if your firewal is also a proxy, then traffic is seen as outcoming,
not forwarded (because client computer is not connected to Internet but
to squid on firewall)
## 2) Filter traffic using TC ##
tc filter add dev eth1 parent 1:0 prio 1 protocol ip u32 match ip src
192.168.0.24 flowid 1:10
tc filter add dev eth1 parent 1:0 prio 1 protocol ip u32 match ip src
192.168.0.35 flowid 1:10
Hope this helps.
prev parent reply other threads:[~2014-07-30 11:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 22:10 SFQ + throttling to specific hosts Roy Kidder
2014-07-30 11:31 ` GGounot [this message]
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=53D8D797.8030108@laposte.net \
--to=g.gounot@laposte.net \
--cc=lartc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.