Andrew J. Schorr wrote:
On Thu, Nov 14, 2002 at 12:26:59PM +0200, Sheldon Hearn wrote:

On (2002/11/13 10:23), Eric Anderson wrote:


Can I ask why the (near) duplicate rule sets in the message you're
referring?  Can I get away with just these two lines:

pass in quick on hme0 proto tcp from any to any port 80 flags S/SA keep state head 20
block in quick from <offender>/32 to any group 20
I'd suggest you go over the HOWTO _very_ carefully; it looks like you
skimmed. :-)

The second rule you specified will _never_ be reached for packets coming
in via hme0, because you pass them _quick_ in the first rule.  From then
on, packets that form part of the initiated stream are passed by the
state table because the first rule does keep state.

Drop the _quick_ modifier from the first rule, and then you're in
business.  Of course, you're also back to a linear scan. :-)

I'm not sure who skimmed, but "quick" has a different meaning when
included in a group head statement.  According to the man page for
ipf:

"If  quick  is used  with  a head rule, rule processing isn't stopped until
it has returned from processing the group."

So the quick in the head statement does not mean that it will stop processing
right away.  Rather, it means that processing will stop after the
group has been processed.  So the second rule above _will_ be reached.
In addition, if processing the group matches a rule *without* quick set, then the quick on the head rule is canceled, and processing will continue past the head rule. E.g.:

1 block in quick on le0 proto tcp all head 10
2 pass in quick on le0 all
3 block in quick proto tcp all port = 6000 group 10
4 block in proto tcp all port = 111 group 10

This ruleset will block packets destined for port 6000, but *pass* packets destined for port 111. The latter will match rule 1, rule 4, and then rule 2 because the lack of quick in matching rule 4 cancels the quick in rule 1.

In other words, it is not sufficient to use quick in a head rule to prevent processing from continuing past that rule. All matching rules encountered in evaluating that head rule must also be quick.

--
Jefferson Ogata <[EMAIL PROTECTED]>
NOAA Computer Incident Response Team (N-CIRT) <[EMAIL PROTECTED]>

Reply via email to