Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Andrew Beverley <andy@andybev.com>
To: J Webster <webster_jack@hotmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: good tutorial
Date: Sat, 05 Feb 2011 19:22:04 +0000	[thread overview]
Message-ID: <1296933724.1617.10.camel@andybev> (raw)
In-Reply-To: <BLU0-SMTP7495DFC8C5F2213D76D1D2F3E90@phx.gbl>

On Sat, 2011-02-05 at 17:48 +0100, J Webster wrote:
> Does anyone have a tutorial recommendation for tc?
> I tried the existing tutorials on LARTC and they were all lacking 
> examples - also the pages look like they were written 10 years ago.
> I want to limit bandwidth per ip address on my server.

If you check the archives there's a discussion going on right now about
this...

You can use a classful qdisc such as HTB, create a leaf for each IP
address, then filter into that leaf using the U32 filters.

Something like this (untested - I've only copied from the list
archives):


tc qdisc add dev eth0 root handle 1: htb r2q 1
tc class add dev eth0 parent 1:0  classid 1:1 htb \
	rate 3000kbit ceil 3000kbit

tc class add dev eth0 parent 1:1 classid 1:100 htb \
	rate 1500kbit ceil 1500kbit prio 3
tc filter add dev eth0 parent 1: protocol ip u32 \
	match ip dst 172.16.254.1/32 classid 1:100
tc qdisc add dev eth0 parent 1:100 handle 100: sfq perturb 2

tc class add dev eth0 parent 1:1 classid 1:101 htb \
	rate 1500kbit ceil 1500kbit prio 3
tc filter add dev eth0 parent 1: protocol ip u32 \
	match ip dst 172.16.254.2/32 classid 1:101
tc qdisc add dev eth0 parent 1:101 handle 101: sfq perturb 2

...


You'll need a leaf class for each IP address, and all the leaf classes
should add up to the parent.

By the way - please start a new email when starting a new thread. If you
reply to a previous email and change the subject then your email will
still appear in the original thread in the message archives.

Andy



  reply	other threads:[~2011-02-05 19:22 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03  2:17 How can I test my tc script? Optimum Wireless Services
2011-02-03 11:01 ` Marek Kierdelewicz
2011-02-03 14:13   ` Optimum Wireless Services
2011-02-03 15:06     ` Marek Kierdelewicz
2011-02-03 16:18   ` Optimum Wireless Services
2011-02-04 13:45   ` Optimum Wireless Services
2011-02-04 16:49     ` Optimum Wireless Services
2011-02-04 19:57       ` Optimum Wireless Services
2011-02-05 12:29         ` Andrew Beverley
2011-02-05 19:32         ` Marek Kierdelewicz
2011-02-05 19:29       ` Marek Kierdelewicz
2011-02-05 20:21     ` Marek Kierdelewicz
2011-02-06  0:05       ` Marek Kierdelewicz
2011-02-06  2:24         ` Optimum Wireless Services
2011-02-04 14:22   ` Michele Petrazzo - Unipex
2011-02-05  2:08     ` Andrew Beverley
2011-02-05 14:58     ` Marek Kierdelewicz
2011-02-05 16:37       ` Andrew Beverley
2011-02-05 16:48         ` good tutorial J Webster
2011-02-05 19:22           ` Andrew Beverley [this message]
2011-02-05 19:33             ` J Webster
2011-02-05 19:51               ` Bob Miller
2011-02-05 22:47                 ` Andrew Beverley
2011-02-05 22:44               ` Andrew Beverley
2011-02-05 17:04         ` How can I test my tc script? Marek Kierdelewicz
2011-02-06  2:12         ` Optimum Wireless Services
2011-02-06 16:13           ` Andrew Beverley
2011-02-07  8:20       ` Michele Petrazzo - Unipex
2011-02-03 19:38 ` Andrew Beverley
2011-02-05  2:44   ` Optimum Wireless Services
2011-02-05  6:07     ` Optimum Wireless Services
2011-02-05 12:27       ` Andrew Beverley
2011-02-06  2:14         ` Optimum Wireless Services
2011-02-06 16:15           ` Andrew Beverley
2011-02-06 16:35             ` Optimum Wireless Services
2011-02-06 17:02               ` Andrew Beverley
2011-02-06 23:27                 ` Optimum Wireless Services
2011-02-08  0:56                   ` Andrew Beverley
2011-02-08  2:11                     ` Optimum Wireless Services
2011-02-08  6:52                       ` Andrew Beverley
2011-02-08  2:20                     ` Optimum Wireless Services
2011-02-08  6:53                       ` Andrew Beverley
2011-02-06 16:44             ` Marek Kierdelewicz
2011-02-06 23:31               ` Optimum Wireless Services
2011-02-08  0:58                 ` Andrew Beverley
2011-02-05 12:35     ` Andrew Beverley
2011-02-06  2:17       ` Optimum Wireless Services
2011-02-06 15:54         ` Andrew Beverley
2011-02-06 16:28           ` Optimum Wireless Services
2011-02-06 17:11             ` Andrew Beverley
2011-02-06 23:33               ` Optimum Wireless Services
2011-02-08  1:01                 ` Andrew Beverley

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=1296933724.1617.10.camel@andybev \
    --to=andy@andybev.com \
    --cc=netfilter@vger.kernel.org \
    --cc=webster_jack@hotmail.com \
    /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