htaccess Block IP Address – Block Access to Files by IP Address

Home Forums BulletProof Security Free htaccess Block IP Address – Block Access to Files by IP Address

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2024
    AITpro Admin
    Keymaster

    If you want to block multiple IP Addresses in a subnet then you would not include the last Octet of the IP Address.

    Examples:  Using 46.119.35. blocks all IP address from 1-256 in the last Octet – 46.119.35.1 through 46.119.35.256.  You can also block from 46.119. to block all IP addresses that start with 46.119.

    1. Add your IP Address blocking code to this Custom Code text box:  CUSTOM CODE BOTTOM HOTLINKING/FORBID COMMENT SPAMMERS/BLOCK BOTS/BLOCK IP/REDIRECT CODE
    2. Click the Save Root Custom Code button.
    3.  Go to the BPS Security Modes page and click the Root Folder BulletProof Mode Activate button.

    # BLOCK/FORBID Spammers etc
    Order Allow,Deny
    Deny from 46.119.35.
    Deny from 46.119.45.
    Deny from 91.236.74.
    Deny from 93.182.147.
    Deny from 93.182.187.
    Deny from 94.27.72.
    Deny from 94.27.75.
    Deny from 94.27.76.
    Deny from 193.105.210.
    Deny from 195.43.128.
    Deny from 198.144.105.
    Deny from 199.15.234.
    Allow from all
    #5169
    AITpro Admin
    Keymaster

    Another approach without ending up with tons of logged 403 errors in your Security Log file would be to redirect by IP address instead of blocking by IP address.

    Note: You could use: REMOTE_HOST instead of using REMOTE_ADDR they are the same thing.

    Note: You will need to create a file called idiots.php and create it in your website root folder. You can copy the WordPress /wp-content/index.php file and rename it to idiots.php and upload it to your root folder. The index.php file displays a blank white page. If you want you can echo a message like “Hello Idiot”.

    Note: Since you are adding an additional RewriteRule then all of the skip rule numbers in the plugin fixes area would need to be changed.

    RewriteRule . - [S=1] would now be RewriteRule . - [S=2]
    RewriteRule . - [S=2] would now be RewriteRule . - [S=3]

    etc….

    You would incorporate/add this code to your existing BPS root .htaccess code.

    RewriteCond %{REMOTE_ADDR} ^(88\.55\.66\.200|99\.100\.4\.1|10\.25\.45\.100)$
    RewriteCond %{REQUEST_URI} !^/idiots\.php$
    RewriteRule ^(.*)$ /idiots.php [R=302,L]

    Add the code above directly above this code shown below that you will find in your root .htaccess file…

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    The End Result:

    RewriteCond %{REMOTE_ADDR} ^(88\.55\.66\.200|99\.100\.4\.1|10\.25\.45\.100)$
    RewriteCond %{REQUEST_URI} !^/idiots\.php$
    RewriteRule ^(.*)$ /idiots.php [R=302,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    #9483
    Nancy Hill
    Participant

    Hi,  I’m using the free version.  Will go pro if I ever generate any site income… I know Bulletproof changes .htaccess files so I thought I would start with it. I’m trying to ip deny many .ru sites  and when entering the ip I get this message: Error:  while opening /home/nfh/public_html/.htaccess Error: while opening /home/nfh/public_html/.htaccess

    I’ve been told that I should put this code in, but where? I disabled all plugins while doing the file access through cpanel. Any suggestions?  Thanks!

    order allow,deny
    allow from all
    #9485
    AITpro Admin
    Keymaster
    #11548
    Terry Chadban
    Participant

    Hi,

    Just a quick question on this — I like the REMOTE_ADDR –>  idiots.php approach rather than the DENY FROM method, because if you get serial spammers it creates a large error file very quickly, but I was wondering if we can still use IP ranges with the REMOTE_ADDR the way you can with DENY FROM?

    I have one very persistent but none too bright comment spammer who has access to a full range of IP addresses from 112.5.234.xxx and the IP Blocker I am currently using will only allow me to block one IP address at a time! Can I use something like to block his full range of IP addresses?

    RewriteCond %{REMOTE_ADDR} ^(112\.5\.234\.)$

    Terry

    #11550
    AITpro Admin
    Keymaster

    Blocking by IP Addresses is not really effective unless you want to block entire countries.  This is a Chinese spammer IP address:  112.5.234.  If you block this IP address then the spammer has millions of other IP addresses that he/she can use and will switch too and most likely will switch to other IP addresses, then when you block those will switch to other IP addresses, etc etc etc etc.  We spent months researching this and conclusively found that a CAPTCHA method is the optimum anti-spammer method to use.  In BPS Pro we created JTC Anti-Spam.  For BPS free users I recommend installing a CAPTCHA plugin.

    Here is the research page for reference:  http://forum.ait-pro.com/forums/topic/buddypress-spam-registration-buddypress-anti-spam-registration/

    See this forum topic link for more explanation about why blocking by IP addresses is completely ineffective and a waste of time: http://forum.ait-pro.com/forums/topic/blocked-attempts-but-no-automatic-blocking-of-ip/#post-24854

    #11591
    Terry Chadban
    Participant

    Kool, thanks for that! I will try using BPS Pro/JTC Antispam and see how that works.

    Terry

    #11596
    AITpro Admin
    Keymaster

    5 human spammer posts / 0 spambot posts since we created and started using JTC Anti-Spam.  Prior to that the number of spambot registrations and posts was off the charts – something like 50,000 per month.  LOL

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.