Block Countries using CSF Firewall On Linux

If you don’t have a need for certain international visitors to your Linux server, It is very easy to block countries on your server by using an csf (Config server firewall). There is an option on your csf to block IP range from different countries. You can follow our guide on installing csf If csf is not install.
Block Countries

See Also:

  • Install CSF (ConfigServer Firewall) Firewall on Linux
  • Use of CSF Firewall in Linux
  • How to Block Traffic from Certain Countries
  • CSF Configuration Files in Linux
  • Email Alert Setup for CSF
  • Block Countries using CSF Firewall

    In your csf configuration file there is an option to block/allow access from an IP range by using country code. For allowing a country to your server you can use the directive ‘CC_ALLOW‘ from the csf configuration file.

    # vim /etc/csf/csf.conf
    
    CC_ALLOW = ""
    

    Similerly you can deny by using the directive ‘CC_DENY‘

    CC_DENY = "RU,CN"
    

    In above Example I have blocked China and Russia.

    Then, just restart CSF

    # csf -r
    

    List of Internet Country Codes

    Enjoy it!

    Comments
    1. 8 years ago

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    The reCAPTCHA verification period has expired. Please reload the page.