Block Countries from your server easily with CSF

June 26, 2013 — 4 Comments

If you don’t have a need for certain international visitors to your Linux server, its easy to block them out!  First, you’ll need to make sure that CSF is installed.  You can follow our guide on installing csf to get this accomplished.  Once that’s done, read on to block access from Russia, China, etc..

Now that CSF is installed, open up your config file (/etc/csf/csf.conf) and search for the country codes section.  It starts on line 570 in the current (v6.15) version.

You’ll see the following:

Here, you’ll want to enter country codes for countries that you would like to block..  here’s an example blocking Russian Federation and China:

Then, just restart CSF!

Boom – you’re done.

You can get country codes from various sites throughout the Internet.  I normally go here: https://www.countryipblocks.net/allocation-of-ip-addresses-by-country.php

Good luck – and let us know how it goes!

If you need assistance with this, I’d be more than happy to set this up for you.  You can contact me through my Linux support site.

4 responses to Block Countries from your server easily with CSF

  1. I am already using your tip to block them by the port. It is always to good to know as many ways as possible to do it though so thanks as always for the great tips.

  2. thank u for this usefull information, it helped me alot

  3. nice article.thanks a lot

Trackbacks and Pingbacks:

  1. Links 30/6/2013: Fedora 19 Days Away, Fedora 20 Feature Previews | Techrights - July 7, 2013

    [...] Block Countries from your server easily with CSF [...]

Leave a Reply