There are many times I wish I could just blame Canada for many of the issues that happens. Lately many parts of Snat.co.uk has been a target of DDOS attacks and it always seems to start off at Canada.
Also, I got a order for a product that I was selling and someone brought it however the person ended up being a scammer (Asking PayPal to refund, then try to get me to refund it as well “outside of PayPal”) and the details that was recorded was that the person came from Canada.
Now, that aside and that Canada is a nice place (Or so I hear, still don’t wanna go there 😉 ) but after this, I decided that enough was enough so I decided to look into many ways to block different country (Not Canada) but other very high risk places like Iran so I decided to have a look into some solutions and I have found three ways that works the best.
The first way was blocking them via .htaccess and that is a failsafe method as it will just work (Apache is needed) however the list of IP can change and therefore you need to update it often (It is possible to do this automatically but that is a post for another day).
Once you have a list of all the IP addresses for the country you want to block (Have a look on Google) that you just put the following code into your .htaccess file (127.0.0.1 is the part you want to change).
deny from 127.0.0.1
allow from all
You also might want to put comments so you know which one is which (# is used for comments). The next method was using MaxFraud and PHP to block them. I won’t go into the PHP code that I used (A post for another day) but it worked just as well as .htaccess as I only needed to re-download the MaxFraud database when it was updated (Or use their API which I believe they have).
My advice, use more then one method to block any users you don’t want accessing your site.
Seeing the title topic says Blame Canada and I am a massive South Park fan (Just look at my name), here is a link to a post that I posted some point in this blog life called – Robin Williams – Blame Canada (South Park).
Need to quote me?
Ellis, M (2008) All the time I wished I could blame Canada. [online] Tweaked for your Pleasure. Available at: https://snat.co.uk/rants/all-the-time-i-wished-i-could-blame-canada.html [Accessed 04 Aug 2021]