procmail
[Top] [All Lists]

Re: How to match IP's

2001-09-05 15:44:32
Rick Leir EPS <rleir(_at_)host(_dot_)ott(_dot_)igs(_dot_)net> writes:
Hi,
Here is something I use to block a range of IP's.
It is ugly and labor intensive.

# XI'AN DATA BUREAU CN 61.134.3.0 - 61.134.20.95
# dtwx.com.cn ([61.134.9.52])
:0
* ^Received:.*(\[61\.134\.[3-9]\.[0-9]*|
\[61\.134\.1[0-9]\.[0-9]*|
\[61\.134\.20\.[0-9]*)
JunkMail.$TODAY


Just 'factor out' the common parts:

        :0
        * ^Received:.*\[61\.134\.([3-9]|1[0-9]|20)\.[0-9]+\]
        JunkMail.$TODAY


My .procmailrc has lots of similar rules.
Is there an easier way? I would like to be able to just 
put '61.134.3.0 - 61.134.20.95' in a rule.  I am tempted to code this into
procmail itself, or would it make more sense to spin off a simple util
program?

Given that you can always express such ranges as regexps and that it's
such a narrow usage, it seems overkill to code up a special syntax
for matching IP ranges.  You could farm it out to an external program,
but that's going to be orders-of-magnitude slower than a regexp like
the above.

It's your call, of course.  If I had more than a handful of ranges to
match I would probably write a program that would generate the regexp
for matching a given range and use that to build the rcfile.


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>