We can make restrictions for the server access based on countries using unique country codes via the CSF interface in WHM.
We can write allow or deny rules based on the requirement. We can get the country code list from: en.wikipedia.org/wiki/ISO_3166-1_alpha-2 Once you have the list, follow the steps provided below to apply the block:
We can write allow or deny rules based on the requirement. We can get the country code list from: en.wikipedia.org/wiki/ISO_3166-1_alpha-2 Once you have the list, follow the steps provided below to apply the block:
- Login to the WHM panel as root and choose the ConfigServer Security & Firewall option using the search option.
- Scroll down and select the option ‘Firewall Configuration’ from the ‘csf – ConfigServer Firewall’ section.
- There you can see the configuration file and find the ‘Country Code Lists and Settings’ from that section.
- Scroll down a bit and you can see the ‘CC_DENY’ section. There you can provide the country codes you need to block the access from as provided in the image below:
- Multiple countries can be added with a comma separation with no spaces in between. For example, “AM, BM, CO” deny access to the countries Armenia, Bermuda, and Columbia as shown in the image below:
- If we need to allow a few countries only and deny all others, better use ‘CC_ALLOW_FILTER’ option there and provide the country list in the same way mentioned before.
- Once the changes are done, press the ‘Change’ button at the bottom to save the changes and then restart the firewall to apply the new settings.