How to Block Countries in CSF Firewall

How to block countries in csf?

In the csf configuration file (/etc/csf/csf.conf), there is an option to block/allow access from an IP range by using country code.

If you are using cPanel, you can also edit this configuration in Web Host Manager -> Plugins -> ConfigServer Security & Firewall -> Firewall Configuration

For blocking a countries access to your server, you can deny by using the directive ‘CC_DENY

CC_DENY = ""

Each option is a comma separated list of CC’s, e.g. “US,GB,DE”

You can view the full CSF country code list here: https://billing.dotblock.com/knowledgebase/241/CSF-Country-Code-List.html

 

For example, if you wanted to block China then your CC_DENY configuration should look like this:

CC_DENY = "CN"

You need to restart the csf service to get the changes to be worked. Run the following command for restarting the csf service (or use the option in Web Host Manager to restart csf)

csf -r

Note that if you receive an error about MM_LICENSE_KEY when restarting CSF, you will want to edit the CC_SRC value in csf.conf and change it from a "1" to a "2":

CC_SRC = "2"

and restart CSF/LFD

csf -r && service lfd restart
  • csf, csf firewall, block, block country, block countries
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

What Do I Do If My Server Has Been Compromised?

Unmanaged servers do not come pre-configured. It is the customer's responsibility to configure,...

Basic Steps To Secure Your Server

  Install a firewall and/or login failure tracker You should always run a firewall allowing...

CSF Country Code List

Below is a full list of CSF country codes that can be used in the CSF Firewall configurations for...

Securing RDP logins on your Windows Server

If you would like to restrict Remote Desktop access to your Dedicated server to an IP address or...