I have a website that needs to block a particular country based on IP address. I am more than aware that IP-based blocking is not a foolproof method for blocking visitors, but it is a necessary step in the right direction.
Since I'm using PHP, what I would do is use a GeoIP database like geoplugin.net. However, I'm curious to know if there's a better way of doing this.
The website is on a shared webserver (I don't have root access) and it is running Apache on centOS. I guess my question is "can an .htaccess file be configured to block by IP using an external source to lookup IP addresses."
http://www.blockacountry.com
Use cautiously...I'm sure there are plenty of people on here that think you are doing the wrong thing by blocking whole countries.
There seems to be a geoip module for apache, but the server admin might have reasons against installing it.
If you find the additional rules causing CPU overhead and latency issues, TechGuard makes an in-line appliance for IP address blocking of inbound and outbound traffic, including commercial block lists of millions of IP addresses tied to malicious activity in countries allowed by your policy. It does all this without impacting network latency or TCP connections, while automatically updating what is equivalent to 12,000 IP ranges a day.