Portal Home > Knowledgebase > Articles Database > How to Create an htaccess file to Block Indonesian IPs


How to Create an htaccess file to Block Indonesian IPs




Posted by blazingtrail, 01-12-2011, 02:55 PM
I would like to use a table of ips from nirsoft.net/countryip/id.html to block Indonesian ips from my site. What is the exact format to use in an htaccess file? for instance, here's the first three lines of ips. How would they be written? From IP -- To IP -- Total IPs 60.253.96.0 -- 60.253.127.255 -- 8192 61.5.0.0 -- 61.5.127.255 -- 32768 61.8.64.0 -- 61.8.79.255 -- 4096 Last edited by blazingtrail; 01-12-2011 at 03:06 PM. Reason: fix table

Posted by OrbitData, 01-12-2011, 03:03 PM
Go to http://www.countryipblocks.net/ You can build an htaccess file on line and then paste it into your site. Keep in mind, doing this in an htaccess file can slow you down a bit if you have a huge list. This is because the web server will load the file for each request. It is better to put them in the httpd.conf file (assuming apache) instead. I've used the list at the above referenced site, but I can't vouch for how up to date it is. Craig

Posted by blazingtrail, 01-12-2011, 03:24 PM
I am on Bluehost and don't have access to the httpd.conf file. The countryblocks tool outputs like this: deny from 60.253.96.0/19 deny from 61.5.0.0/17 deny from 61.8.64.0/20 deny from 61.94.0.0/16 deny from 61.247.0.0/18 That doesn't look like it takes into consideration the ip range 60.253.127.255 (for example on the first ip block) or am I misreading what the 0/19 actually means? In other words, where are the remaining ips - up to the 60.253.127.255 block - represented?

Posted by OrbitData, 01-12-2011, 03:44 PM
A /19 covers - 60.253.96.0 - 60.253.127.255. It means there are 19 bits in the subnet mask. i.e. 255.255.224.0 or 8+8+3+0=19. You get the masks by by counting the bits in each octet. 128 64 32 16 8 4 2 1 = 255 3 bits = 128+64+32 or 224 Confused? It takes a bit to get it, but it's not too hard. There are online CIDR calculators to help. Are you trying to do a complete block or just block Wordpress splog signups? The format for a complet .htaccess deny is: order allow,deny deny from 60.253.96.0/19 deny from 61.5.0.0/17 deny from 61.8.64.0/20 deny from 61.94.0.0/16 deny from 61.247.0.0/18 # allow from all If you just want to block a Wordpress signup page use: order allow,deny deny from 60.253.96.0/19 deny from 61.5.0.0/17 deny from 61.8.64.0/20 deny from 61.94.0.0/16 deny from 61.247.0.0/18 # allow from all BTW: A list this short will have no performance effect.

Posted by blazingtrail, 01-12-2011, 05:54 PM
Thank you for your replies, I am definitely understanding a bit more. I will actually be using a much larger list, I just wanted to use a few as an example to understand how it works a little better and I believe I now do.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
ipv6 ip addresses. (Views: 761)
MCHost Email Problems (Views: 685)


Language: