Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Block an IP address range using the .htaccess file

I have detected that a range of IP addresses may be used in a malicious way and I don't know how to block it.

I would like to block the range 66.249.74.* from accessing my website by using the .htaccess file.

like image 681
Msy Marina Avatar asked Aug 28 '13 08:08

Msy Marina


People also ask

How do I block an IP address from an htaccess file?

Head to Country IP Blocks homepage. Select the countries you want to block or allow. On the Select Format section, choose Apache . htaccess Deny or Apache .

How do I block an IP address in Apache?

Tutorial Apache - Blocking an IP address networkInstall the Apache server. Enable the required Apache modules. Edit the Apache configuration file for the default website. Add the following lines to this configuration file.


2 Answers

You could use:

Order Allow,Deny Deny from 66.249.74.0/24 Allow from all 

Or you could use this:

RewriteEngine on RewriteCond %{REMOTE_ADDR} ^66\.249\.74\. RewriteRule ^ - [F] 
like image 138
Prix Avatar answered Oct 02 '22 14:10

Prix


Use just the first 3 octets

Order Allow,Deny Deny from 66.249.74. Allow from all 
like image 45
Howard Lee Harkness Avatar answered Oct 02 '22 13:10

Howard Lee Harkness