Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Anders Fugmann <afu@fugmann.dhs.org>
To: "\"Luís Fernando C. Talora\"" <talora@4networks.com.br>
Cc: "netfilter.org" <netfilter@lists.netfilter.org>
Subject: Re: -m limit
Date: Fri, 06 Sep 2002 11:51:54 +0200	[thread overview]
Message-ID: <3D787ABA.80801@fugmann.dhs.org> (raw)
In-Reply-To: 014501c25512$5932a9e0$0101a8c0@osbourn

Luís Fernando C. Talora wrote:
> Fellows,
> 
> I'd like some help using ntefilter "limit" module.
> 
> If I put something like the following in a firewall script (to limit tcp syn
> packets):
> 
> # Block tcp syn floods
>      $IPTABLES -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
> 
>         (and then, latter, I put the following)
> 
> # Access to my web server
>      $IPTABLES -A FORWARD -p tcp -d $MY_WEB_SERVER --dport 80 -j ACCEPT

This is definatly dot what you want. As it is now, 1 syn packet is 
acceted per sec, regardless of destination port or address.

> 
> In this example, will a tcp syn flood be barred by the first line? Is it the
> second line allowing more than 1 packet per second? Do I have to use "-m
> limit --limit 1/s" on the second line too (and all lines that allow incoming
> packets)?
No. If you want to limit all syn packets you mist create a new chain. 
like this:

$IPTABLES -N LIMIT_SYN
$IPTABLES -A LIMIT_SYN -m limit --limit 1/s -j RETURN
$IPTABLES -A LIMIT_SYN -j DROP
$IPTABLES -A FORWARD -p tcp --syn -j LIMIT_SYN

This contrsruction limit syn to one per sec by dropping syns above the 
limit (Acts like a filter). You then need other rules to actually accept 
the syn packet:

$IPTABLES -A FORWARD -p tcp -d $MY_WEB_SERVER --dport 80 -j ACCEPT

If you only want to limit http requests, you should  use
$IPTABLES -A FORWARD -p tcp -d $MY_WEB_SERVER --dport 80 --syn \
	-m limit --limit 1/s -j ACCEPT

Hope it helps.

-- 
Author of FIAIF
FIAIF Is An Intelligent Firewall
http://fiaif.fugmann.dhs.org



      reply	other threads:[~2002-09-06  9:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-05 19:28 -m limit Luís Fernando C. Talora
2002-09-06  9:51 ` Anders Fugmann [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=3D787ABA.80801@fugmann.dhs.org \
    --to=afu@fugmann.dhs.org \
    --cc=netfilter@lists.netfilter.org \
    --cc=talora@4networks.com.br \
    /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