Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Block Countries from your server with CSF  (Read 5189 times)

0 Members and 1 Guest are viewing this topic.

Eby Sebastian

  • Newbie
  • *
  • Posts: 14
  • Karma: +1/-0
Block Countries from your server with CSF
« on: October 31, 2013, 12:38:10 pm »

CSF is one of best Linux firewall and it is not just a simple iptables firewall, it is a complete security suit that can turn your server into a robust firewall and intrusion detection system (IDS).

One of the most exciting options this firewall has is the ability to block entire countries.

Open your CSF configuration file (/etc/csf/csf.conf) and search for the country codes section.

So, in order to block a specific country, you just need to add the country code into CC_DENY variable.

To block all traffic from China and Pakistan, you can set as follows.

=======
CC_DENY = "PK,CN"
=======

Then, just restart CSF to make the changes effective.

=======
#csf -r
=======

You are done!!!


Country codes are available in the link below.

https://www.countryipblocks.net/allocation-of-ip-addresses-by-country.php

I suggest you to do this carefully due to below reasons:

* It will completely reject traffic from the specified countries and thus it will reject requests from legitimate customers too.
* This will block search engine bots that try to access your websites from the datacenters located in the blocked country.
* This will considerably use server resources to load all the blocked ranges.

Good luck  :)
Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!