Linux Netfilter discussions
 help / color / mirror / Atom feed
From: richard lucassen <netfilter@lucassen.org>
To: netfilter@lists.netfilter.org
Subject: Re: iptables jump to userdefined chain and ESTABLISHED,RELATED rules
Date: Sun, 12 Oct 2003 23:40:49 +0200	[thread overview]
Message-ID: <20031012234049.587cadaa.netfilter@lucassen.org> (raw)
In-Reply-To: <1065984839.4919.59.camel@elendil.intranet.cartel-securite.net>

On Sun, 12 Oct 2003 20:54:00 +0200
Cedric Blancher <blancher@cartel-securite.fr> wrote:

> Not working for SSH.
> 
> In fact, it should work. A TCP SYN flaged as NEW will be sent to
> CH_SSH chain, then be accepted by CH_SSH rule that allows NEW packets.
> Then further packets are going by. They are ESTABLISHED.
> 
> They match first rule so they are sent to CH_SSH chain. They do not
> match the rule, for thieses packets are not NEW. So they hit end of
> user chain and are returned to FORWARD chain, rule 2. They match rule
> 2 and then get accepted.

Yes, sorry, you're right, but I forgot to mention that I have a cleanup
rule at the end of the CH_SSH:

$IPT -A CH_SSH -j DROP
 
> If it does not work as your's, then you have a drop all rule at the
> end of CH_SSH chain (I suppose) that prevents packet from returning
> from user chain (CH_SSH here) to calling chain (FORWARD here).

You got it right ;-)

> To me, the best way to handle this is :
> 
> # ESTABLISHED and RELATED packets are accepted anyway
> # We accept them first as they are most treated packets
> $IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
> 
> # Then we care of each proto.
> $IPT -A FORWARD -p tcp --dport 22 -j CH_SSH
> [...]
> $IPT -A CH_SSH -m state --state NEW -s 1.2.3.4 -j ACCEPT
> 
> Case 3 works because you enforce ESTABLISHED,RELATED accept in your
> use chain.
> 
> I really do think that 1st case is the best way to handle, as it
> implies less rules evaluation for each packet.

Ok, thanks a lot, it's much clearer now :)

R.

-- 
___________________________________________________________________
Recursion: see recursion

+------------------------------------------------------------------+
| Richard Lucassen, Utrecht                                        |
| Public key and email address:                                    |
| http://www.lucassen.org/mail-pubkey.html                         |
+------------------------------------------------------------------+


  reply	other threads:[~2003-10-12 21:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-10 11:26 iptables jump to userdefined chain and ESTABLISHED,RELATED rules richard lucassen
2003-10-11 16:26 ` Cedric Blancher
2003-10-11 17:45   ` CAM IT Solutions
2003-10-12 11:16     ` Willy TARREAU
2003-10-12 17:53       ` richard lucassen
2003-10-12 18:54         ` Cedric Blancher
2003-10-12 21:40           ` richard lucassen [this message]
2003-10-12 19:02         ` Cedric Blancher
2003-10-12 15:10   ` Joel Newkirk
2003-10-12 15:15     ` Cedric Blancher
  -- strict thread matches above, loose matches on Subject: below --
2003-10-09 20:20 richard lucassen

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=20031012234049.587cadaa.netfilter@lucassen.org \
    --to=netfilter@lucassen.org \
    --cc=netfilter@lists.netfilter.org \
    --cc=reply2@lucassen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox