Server Administration & Management

How to block a country using CSF

Login to WHM-cPanel configuration via WHM

1. WHM
2. Plugins
3. ConfigServer Security & Firewall
4. Firewall Configuration)


1. Login via SSH

# vi /etc/csf/csf.conf

What you are looking for is “CC_DENY

First, you will want to get a list of ISO Country Codes to allow.

http://www.countryipblocks.net/country-blocks/ “OR”

http://www.ipdeny.com/ipblocks/ “OR”


For example, if you only wanted United States, Canada, Great Britian, Australia, and Mexico to be whitelisted, you would specify:


What this will do is download a list of IP ranges belonging to those countries, then add them to a deny list, that is, deny all specific countries’ IP ranges. So, United States, Canada, China will not be able to connect, etc..

Once you have change this in your configuration, don’t forget to restart your firewall to apply the new configuration.


May 1, 2011 Posted by | CSF, Firewall, Security | , , , | 3 Comments