How to Block Countries in CSF Firewall Print

  • csf, csf firewall, block, block country, block countries
  • 3

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

Was this answer helpful?

« Back