Search code examples
regexiisipurl-rewritingwhitelist

Regex for whitelisting specific IP segments


I need a regex that I haven't been able to figure out:

How do I take something like this:

60.70.80.90/25

And turn it into a regex that will match IPs in that range?

That IP address is just a dummy; the actual IP range is different. Is there a way to turn that into a regex, without enumerating every single address in that range? For example, I know I could do this:

60\.70\.80\.91|...

But I'd rather not have to enumerate all those addresses. Anyone able to figure out a regex for this?

This will be used in an IIS rewrite rule to whitelist specific IP's, and deny access to all others.

EDIT: If you have a better idea for whitelisting IP's other than what I've suggested, feel free to suggest accordingly.


Solution

  • <Limit GET POST HEAD>
      Order Deny,Allow
      Deny  from all
      Allow from 60.70.80.90/25
    </Limit>