Block whole country with CSF firewall or Apache .htaccess

There are lot of ways to block users to access your web sites but we will mention only two of them. First one is to use mod_geoip for Apache web server if you are on VPS hosting server or dedicated server. After you have the Apache module compiled just use your .htaccess file to block whole countries IP addresses. The second way is to use CSF firewall which is based on Linux iptables firewall.

Using VPS hosting or dedicated Server blocking whole countries IP address ranges using the firewall is a lot better alternative for you. Also the overhead for the VPS server or dedicated server is a lot less. This will save you some CPU power and RAM memory resources. If you like to ban countries like China, Turkey or Iraq like you do not like to ship a goods to there for some reason, you can block the whole country IP addresses from accessing the web sites on your server. This may help you too to reduce the number of fraudulent orders for your online store.

Will will show you the steps you need to do on your VPS or dedicated server hosting when using ConfigServer Security & Firewall (CSF) based on iptables:

1. Open the cPanel's WHM admin panel for your VPS server or dedicated server and find "ConfigServer Security&Firewall" link
2. Click the "Firewall Configuration" button after that
3. Scroll down the page or use the "find" option in your web browser to the section with text "CC_DENY". These are comma separated list of 2 letter country codes. You can find the country codes at -
4. For every country IP address range you like to deny/block, just enter those letters in the field in the way separated by commas

  • 103 Users Found This Useful
Was this answer helpful?

Related Articles

Daily bandwidth limit

No. The traffic limits for each hosting are monthly and there are no other restrictions on how it...

Do you offer DNS hosting

If you buy shared web hosting plan with us, you get the right to quickly and easily manage DNS...

Do you support SSI (server side includes) on html pages

Yes we do. SSI or Server Side Includes is supported by all hosting plans.  

Web hosting limit of the CPU time (CPU usage)

There is no limit on CPU time used per unit time of shared web hosting plans. If your hosting...

Web hosting with unlimited domains

Hosting of unlimited domains means that you can add your unlimited domains to your hosting...