There has been some comments in my old posts trying to use generated country lists in Apache .htaccess. This approach is wrong, and I will show you much better way how to block or allow specific country.
My original article about this topic is more that year old and was using Regional Internet Registries (RIRs) list as source and was in python. This post will describe other simple solution how to generate some country IP ranges list.
In my previous post I have showed how to easily generate IP range assigned to some country. I have modified this previous script to generate IP blocks for all countries and put it online for free download and usage.