Report this

What is the reason for this report?

Block countries from accessing my website

Posted on July 11, 2014

Hello. Can you help me block specific countries from accessing my website.

Thank you.

Sincerely,

Chris Anthony



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Why? What are you trying to accomplish by doing this? How are you going to determine the “country” of an IP? These questions can change the answer completely.

How detailed do you want the list. If you want to do mass blocking you could use https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml

For instance if you want to block all APNIC (Asia Pacific ips) firewall off all the APNIC /8 entries.

http://www.ip2location.com/free/visitor-blocker lets you do it by country but that take a lot of time to compile a list unless you are targeting only a couple countries.

Of course they could always use a proxy to bypass this.

I recommend you setting up your website with Cloudflare, I believe that they have a feature that allows you to block certain countries from accessing your website.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.