All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gáspár Lajos" <swifty@freemail.hu>
To: "Brendan S (Scratch User)" <gobnat@optusnet.com.au>
Cc: netfilter@lists.netfilter.org
Subject: Re: Iptables and rate limiting per ip address
Date: Fri, 13 Oct 2006 10:01:52 +0200	[thread overview]
Message-ID: <452F47F0.2040108@freemail.hu> (raw)
In-Reply-To: <452F3949.2050502@optusnet.com.au>

Brendan S (Scratch User) írta:
> Hi  
>
> I am an iptables beginner. I want to set up my firewall to rate limit incoming packets based on a particular source IP address (but not any other IP).
>
> I understand that there are dstlimit and hashlimit options for iptables.  It is not clear to me whether these apply the same limit (x packets/sec) to each ip address (ie all IP addresses limited at x packets/sec) or whether their action can be applied to a single address (I suspect the former).
>
> If it is the latter, can the hashlimit switch be limited by (eg) -s?   Alternatively can I jump past the rule for other ip addresses?
>
>   
You can use -s switch
> Would either of these work?
> ...
> -A src_limit -s !<limit_ip> -j ACCEPT
> -A src_limit -m hashlimit --hashlimit 2/min --hashlimit-burst 10 --hashlimit-mode srcip,dstport --hashlimit-name per_src --hashlimit-htable-gcinterval 60000 --hashlimit-htable-expire 300000 -j ACCEPT
>
>   
1. Accept EVERYTHING from EVERYONE except <limit_ip>
2. Accept EVERYTHING ELSE (from <limit_ip>) if hashlimit module permits

> ...
> or
>
> -A src_limit -s <limit_ip> -m hashlimit --hashlimit 2/min --hashlimit-burst 10 --hashlimit-mode srcip,dstport --hashlimit-name per_src --hashlimit-htable-gcinterval 60000 --hashlimit-htable-expire 300000 -j ACCEPT
>
>   
1. Accept from <limit_ip> if haslimit module permits
> Thanks
>
>
> Brendan
>
>   
Do not forget the DROP policy in the chain...

Swifty


      reply	other threads:[~2006-10-13  8:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-13  6:59 Iptables and rate limiting per ip address Brendan S (Scratch User)
2006-10-13  8:01 ` Gáspár Lajos [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=452F47F0.2040108@freemail.hu \
    --to=swifty@freemail.hu \
    --cc=gobnat@optusnet.com.au \
    --cc=netfilter@lists.netfilter.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.