How to Allow and Deny access in server for Countries using CSF.
It is very easy to allow and deny Countries using CSF. We must know the IP ranges to deny and allow countries. IP ranges vary from countries to countries. We can't remember all the IP Ranges. So country codes are available to use in our CSF. There are TWO variables (directives) available in CSF configuration file.They are CC_ALLOW and CC_DENY.
Login as root user in your server.
-> su root
Open CSF configuration File.
Find the CC_ALLOW varaible and add the countries which you like to allow
then Find CC_DENY variable and add the countries which you like to deny.
CC_ALLOW = ”IN,US”
CC_DENY = “CN,NL”
In the above examples We have allowed access to india and united status contries and denied to china and netherlands.
After you make the changes, save the file and quit your text editor.
You have to restart your CSF firewall for the changes to take effect.
The above command will restart the CSF firewall.
Here are some of the country codes
You can search about country codes and IP Ranges alloted for countries in any one of the search engine. Check the following URLs to know about country code and IP Range.