Is it possible to block countries from server using CSF?
Yeah, It is very easy to block countries on your server by using an csf (Config server firewall). There is an option in the csf to block IP range from different countries.
Config Server Firewall is abbreviated as CSF. CSf is the most commonly using firewall application to secure Linux servers. CSF has wide range of options to manage Linux firewall via comman-line and from the control panel.
CSF helps to configure server firewall easily and simply.
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. Here I’m going to explain how to allow or deny IP range using this feature.
For allowing a country to your server you can use the directive ‘CC_ALLOW‘ from the csf configuration file.
CC_ALLOW = ""
Similerly 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 need to restart the csf service to get the changes to be worked. Run the following command for restarting the csf service.
Refer this link for Other useful csf command
Refer this link for more details : Allocation of IP addresses by Country
Install and configure csf on CentOS
CSF commands for Unix/Linux servers
Csf command not found in WHM/cPanel server
6 thoughts on “How to block countries accessing server using csf?”
Can i use a * for all counters and onley fill in the allow part of countries that are allowed?
Searching from long time, finally find this, thanks for sharing important information.
You are most welcome, Yadav!!
Is there any way this configuration can stay definitively? Because after 24hs the CSF goes back to block the IPs. Thanks!