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 | , , ,


  1. Thank you for spending some time to line this all out for people like us. This particular posting was incredibly helpful to me.

    Comment by Dorinda Fogle | June 15, 2011 | Reply

  2. Thanks a ton for spending some time to line all of this out for us. This kind of blog post was in fact incredibly helpful to me.

    Comment by Gordon Dukeshier | June 15, 2011 | Reply

  3. Are you psychic? You must be as your writing so flawlessly satisfies the questions I have in mind on this topic. I only put several words in the search results and I am quite thankful your blog sprang up.

    Comment by water | June 16, 2011 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: