First of install the csf on the serer after that Click on the Firewall Configuration button to open the configuration file and page, scroll down to the Country Code Lists and Settings section.
## Use the CC_DENY field to block by country code:
The CC_DENY field accepts two-letter country codes.
such as â€œUSâ€ for the United States of America, â€œGBâ€ for Great Britain, and â€œDEâ€ for Germany.
IN this way the specific country code traffic has deny to server.
This will actually depends on the internet provider you are using. VPN is now a trend. If you tend to use VPN and want to block countries for your site, I'd prefer not to do it. Because once you logged into another device, your settings will be refreshed. Better have a suitable internet provider first. Then follow the steps the others have given. Ciao
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 = ""
Similarly, 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.