----- Original Message ----- From: "Antony Riley" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 13, 2002 12:40 PM Subject: Re: Maximum number of rules?
> On Wednesday 13 November 2002 17:28, Eric Anderson wrote: > > > i've implemented groups and it's not that confusing, documentation is > > > a bit terse, but I heard that is being updated. I grouped rules based > > > on interface like: > > > > > > block in quick on hme0 all head 20 > > > pass in quick <something> group 20 > > > .... > > > > > > you clould basically put anything in the 'head' rule and it will work > > > more or less as you'd explect. The howto has some usefull remarks. > > > > > > Now I have only a small ruleset, but it helps to keep thing organised.... > > > > I just finished re-reading the groups section in the how-to and I'm not > > sure it's what I'm looking for. > > > > Let me reiterate: I've got a rules list of about 2500 items, each of > > them blocking a single IP address which has been misused (typically an > > misconfigured anonymous proxy): > > > > block in quick on hme0 proto tcp from w.x.y.z/32 to any > > > > I'm not sure how groups would help me with this? All incoming packets > > are: > > > > a) on the same interface > > b) the same protocol (http) > > c) basically the same type of packets that I'm trying to block > > > > so there's no way to "shortcut" the list. It's going to have to be > > scanned each and every time. Or am I missing something? > > However, the only packets you need to check against your ruleset, are those > with SYN set.... > > pass in on hme0 proto tcp from any to any port 80 flags S/SA head 20 > pass in quick on hme0 proto tcp from any to any port 80 flags S/SA keep state > > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > block in quick on hme0 proto tcp from <offender>/32 to any group 20 > .... > > This way, only SYN packets without ACK set, to port 80 would be checked > against your filter rules for offending IP addresses. > > Anything which gets through this will cause an entry in the state table, and > match further connections without a problem. > > At least, that's the theory ;) > > (Ok, I've not used groups before, but then our firewall ruleset isn't that > complicated....). > > -Antony We use groups extensively and the above rules can be simplified quite a bit. You also need to use the "block in quick" syntax to keep the packets that go into the group from also continuing on through your other rules. You also need to continue to use the "quick" option for all the rules in the group. If you forget and do not use it the "quick" toggle will be reset and the packets will continue to be processed by the rules following your group. Since the filter to get into the group already limits where the packet comes from and its protocol you really don't need to check all that again. I think the following would suffice: block in quick on hme0 proto tcp from any to any port 80 flags S/SA head 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 block in quick from <offender>/32 to any group 20 ... pass in quick from any to <legitimate port 80 receivers on your network> group 20 (at this point all other group 20 traffic is dropped) (put your other non-port 80 rules here without the group 20 suffix) If you wish you can also include the "log" option in the above rules to keep track of when they are used, although in this case just getting the hit counts from ipfstat might be sufficient. With that info you could probably automatically remove those rules that have not received a hit in a reasonable amount of time. -- James A. Robbins Network Engineer The Ohio State University Chemistry Department
