Linux - Block access from specific countires, How to Allow and Deny access to server for Countries
Block access from specific countiresHow to Allow and Deny access in server for Countries using CSF.
As a admin we will be in a situation to allow and deny Countries using to access our websites or webcontents, this can be easily achieved by using CSF. It is a firewall and to achieve this we must know the IP ranges to deny and allow countries. IP ranges vary from countries to countries. To make ourself feel easire we can block websites using county cod insted of remembering all the IP Ranges. 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.
# suOpen CSF configuration File.
# vi /etc/csf/csf.conf
Countries to be allowed
# CC_ALLOW = "IN,US"
Find CC_DENY variable and add the countries which you like to deny.
# CC_DENY = "CN,PK"In the above examples We have allowed access to india and united status countries and denied to china and pakistan. 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.
# csf -rThe above command will restart the CSF firewall. Here are some of the country codes
You can search about country codes and IP Ranges allocated for countries in any one of the search engine. Check the following URLs to know about country code and IP Range.
The topic on Linux - Block access from specific countires is posted by - Math
Hope you have enjoyed, Linux - Block access from specific countiresThanks for your time