Block all traffic from Russia to coming your site

Whether you want to say “no!” to Putin’s war or you just want to block Russian hackers from attacking your website, the solution is as easy as:

  1. Connect to your website via FTP and download current version for .htaccess file from there
  2. Make a copy of this file, just in case…
  3. Go to Country IP Blocks website
  4. Search for Russian Federation and check the checkbox next to it
  5. Scroll the page all the way up and make sure that Apache .htaccess Deny is selected
  6. Click Create ACL button and copy all the content from ACL Results list that will appear
  7. Paste it at the end of your .htaccess file and save the file
  8. Upload it back to your website via FTP overwriting the existing file

Sure, this is not the ultimate solution. Use of proxy servers, Tor networks, botnets and other techniques for spoofing actual IP address will get them through your “so called firewall”. Also, IP address assigmnets changes often, so Country IP Blocks database might already be out-dated (if fact, it is). But, hey!, it’s always something. As good for the start as anything else. And surely better than doing nothing.

The result

When any visitor, using any IP address from the list you’ve just added to your .htaccess file will try to visit your website, they’ll hit the following error instead:

Latency

I have read on some Cisco forums that eve n with those 500 kB added to .htaccess file, pages serving latency drops down by just 1 millisecond. So this is fairly acceptable.

How to test it

Well the simplest and the most obvious method is to temporarily block yourself.

  1. Open any of your website to make sure it is still working
  2. Ask Google, what is your IP address and copy it
  3. Paste it at the end of .htaccess file, prepending it with deny from
  4. Replace last part with 0/19 to change single IP address into address block
  5. Upload updated file your FTP server
  6. Go back to your website and hit F5 to refresh it and check the results
Turn 93.175.64.111 example IP address into 93.175.64.0/19 when adding to .htaccess file

Of course, don’t forget to revert this process after testing is completed! :)

Afterword

Note that Country IP Blocks website is cited by many sources as very reliable source of IP addresses, but it list them without any relationship to any existing ISP. If you’d like to see Russian IP addresses split by ISP then you may consider this source (though it seems a bit old and outdated).

Leave a Reply