Guide on how to block specific countries using CSF software firewallsGuide on how to block specific countries using CSF software firewalls

There are many firewall software that you can use, but here we will share how to block certain countries using ConfigServer Security & Firewall (CSF) firewall software.

  1. Make sure you have installed the CSF firewall software. Please refer to this tutorial if you don't understand the basics of the CSF firewall.
  2. Open the /etc/csf/csf.conf file and locate the PART:Country Code List and Settings section.
  3. In order for the firewall to read which country this ip address belongs to, an additional license is needed, namely from MaxMind. You can register and get a free license on this page.
  4. Fill in the configuration as follows:
    MM_LICENSE_KEY = <<key obtained>>
    CC_SRC = 1

  5. At this stage you can set which countries you want to block.
    CC_DENY = CN,BR

    This means that China and Brazil are blocked. In addition to country codes, you can also block certain ASNs.

 

What if you want to block all countries but only whitelist certain countries?

  1. Here you can utilize the CC_ALLOW or CC_ALLOW_FILTER feature (other than the country set, the connection will automatically be dropped).
  2. CC_ALLOW allows access through all ports on the firewall, for this reason it may be of very limited use and it is recommended to use CC_ALLOW_FILTER
  3. CC_ALLOW_FILTER is an alternative to CC_ALLOW which allows access from certain countries but still takes into account existing port and packet filters.
    Contoh penggunaan :

    CC_ALLOW = ID

    This means you whitelist Indonesia and block countries other than Indonesia.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.