All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Oester <kernel@linuxace.com>
To: Nick Edwards <nick.z.edwards@gmail.com>
Cc: Netfilter user mailing list <netfilter@vger.kernel.org>
Subject: Re: rate limits
Date: Sat, 18 Jan 2014 20:01:11 -0800	[thread overview]
Message-ID: <20140119040111.GA22074@home> (raw)
In-Reply-To: <CAMD-=VLUemcvn4GG6cP9SEyMP4O605s=ZK2-OGDUN=hYd2g9vQ@mail.gmail.com>

On Sun, Jan 19, 2014 at 12:43:56PM +1000, Nick Edwards wrote:
> Hi,
> We have some rate limits on port 80 only, they work as intended
> (almost) and we are happy with the outcome (almost)
>
> /usr/sbin/iptables -A INPUT -i lo -j ACCEPT
> /usr/sbin/ip6tables -A INPUT -i lo -j ACCEPT
> /usr/sbin/ip6tables -A INPUT -s fe80::/10 -j ACCEPT
> /usr/sbin/ip6tables -A INPUT -d ff00::/8 -j ACCEPT
>
> /usr/sbin/iptables -A INPUT -s 199.x.x.x/22 -j ACCEPT
> /usr/sbin/iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
> /usr/sbin/ip6tables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
>
> ..some other rules for other ports...
>
> /usr/sbin/iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m
> recent --set
> /usr/sbin/iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m
> recent --update --seconds 5 --hitcount 2 -j DROP
> /usr/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
>
> /usr/sbin/iptables -A INPUT -p tcp --dport 1:1023 -j DROP
>
> We obviously dont want our 199.x.x.x/22  limited but it is, I thought
> being before this rule, it would be immune, also, if we use localhost,
> it too is limited, I guess its because we use -I which inserts at top
> of rules, but if we used -A in the two recent rule lines we found it
> didnt always work at all?
>
> any suggestions?

Yes, don't use -I to insert the limit rules at the very top of the INPUT
chain.  But if you insist upon doing so, exempt your LAN from the rules
by adding "-s ! 199.x.x.x/22" to the two recent rules.

Phil

  reply	other threads:[~2014-01-19  4:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-19  2:43 rate limits Nick Edwards
2014-01-19  4:01 ` Phil Oester [this message]
2014-01-19 20:49   ` Neal Murphy
2014-01-22  2:00     ` Nick Edwards

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=20140119040111.GA22074@home \
    --to=kernel@linuxace.com \
    --cc=netfilter@vger.kernel.org \
    --cc=nick.z.edwards@gmail.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 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.