1

I can't find a good reference though my understanding is that ranges in an IPv4 address are:

a.b.c.d

I wish to block only the C ranges starting with 51.15.51.0 and ending with 51.15.142.255.

I have tried things like Deny for 51.15.51/142 in the past (the / operator only seems to work for the d range) so this breaks the entire website with an HTTP 500 server error.

Additionally if I use Deny from 51.15 it would block ranges below c-51 and above c-142 which I don't want to do.

How do I efficiently block 51.15.51.0 through 51.15.142.255 in the htaccess file?

4
  • There is a better link but on a different site How to Block an IP address range using the .htaccess file Commented Feb 15, 2023 at 18:37
  • 1
    @RohitGupta The Webmasters question is a "better" reference IMO (both answers). It gives all the up-to-date information/tools to answer this question. The SO question does not and is arguably out of date.
    – MrWhite
    Commented Feb 16, 2023 at 0:30
  • "so this breaks the entire website with an HTTP 500 server error" - And you are using for instead of from (but maybe that's just a typo). However, Deny is also deprecated on Apache 2.4 and moved to mod_access_compat (an extension not installed by default). This is also mentioned in the linked question.
    – MrWhite
    Commented Feb 16, 2023 at 1:12
  • Also, don't necessarily discount regex. The IP range 51.15.51.0 to 51.15.142.255 isn't "too bad" to convert to regex (since it's just one octet that varies). eg. ^51\.15\.(5[1-9]|[6-9]\d|1[0-3]\d|14[012])\.
    – MrWhite
    Commented Feb 16, 2023 at 1:17

0

Browse other questions tagged or ask your own question.