Block IP range in htaccess file

I manage the site and the site is built in Wordpress. It receives ENORMOUS amount of traffic from bots, and we want to block all of them except important bots, such as Google Yahoo Bing Baidu. We use cloudflare, and I want to block them from two layers, the Cloudflare firewall and the htaccess file. In the htaccess file, I know how to block one IP address and the last final IP addresses of an IP range, e.g. 123.123.123.0/16

However, I need to block the following IP addresses 69.30.192.0 - 69.30.255.255 93.55.115.64 - 93.55.115.71

How do you set the rules for this in your htaccess file? Cloudflare seems to adhere to the same rule.

+6
wordpress .htaccess
source share
3 answers

You almost got it. The designation / 16 is actually called the CIDR Designation .

The number indicates how many bits correspond from left to right. The wiki page explains this in detail.

Or ... you can just take my word for it and use a tool like this that I found: http://www.ipaddressguide.com/cidr#range

Then you can use deny from your .htaccess in the same way as for one ip with the given values:

Order Allow,Deny Deny from 69.30.192.0/18 Deny from 93.55.115.64/29 Allow from all 
+3
source share

Not sure how reliable the source is, but it's from the watch.

http://www.clockwatchers.com/htaccess_block.html

To block a single IP address

 order allow,deny deny from 127.0.0.1 allow from all 

This will reject all GET and POST requests made at IP address 127.0.0.1, instead an error message will be displayed.

To block multiple IP addresses, list them one at a time

 order allow,deny deny from 127.0.0.1 deny from 127.0.0.2 deny from 127.0.0.3 allow from all 

To block the entire ip range

 deny from 127.0.0 

This will disable access for any user with an address in the range 127.0.0.0 to 127.0.0.255.

Edit: just found the same question here.

How to block a range of IP addresses using a .htaccess file

It seems the answers are similar too.

+2
source share

The answer from @Nick is good, so on the .htaccess setup side you have to go your own way.

My answer will be about another problem found in your question: you are ready to block the range of IP addresses 69.30.192.0 - 69.30.255.255, but a quick search in the ARIN database (WHOIS for IP addresses) shows that this range is not owned by one person .

In fact, by doing this, you can potentially rob your site of non-bots.

For example:

69.30.192.0 - 69.30.192.31 belongs to LEAKY ****. COM

...

69.30.193.0 - 69.30.193.15 applies to TA *****, Abdelkader

and etc.

+1
source share

All Articles