Block Countries from your server easily with CSF

Rob —  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.

Related posts from Linux Brigade!

  • LFD: Excessive resource usage If you run the CSF/LFD firewall on your server then you’ve no doubt seen the emails complaining about high resource usage for various accounts. This small tutorial will show you how to […]
  • Keep your WordPress site secure!Keep your WordPress site secure! I work for a hosting company. On average, I’ll clean up at least 3-4 WordPress sites each month for our clients. Most of the time, they’re running on old versions of WordPress and have […]
  • Enable statistics in Configserver Firewall (CSF) I’ve noticed recently that a new install of CSF won’t have statistics enabled by default.  Here’s how to enable them…

    Edit your /etc/csf/csf.conf file and change:

    ST_ENABLE = […]

  • Untangle your networkUntangle your network Whether you’re the admin of your office network or your home network (or both), it’s always a good idea to have security and order in place. Untangle is software that you can install as […]
  • cPanel / CSF: Fix 500 internal server error or 404 for the CSF GUI I’ve run into this a couple times – where I’ll spin up a CentOS/cPanel machine, then run a cpupdate (/scripts/upcp) to get cpanel up to date.  I’ll then go into the configserver firewall […]

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

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*