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:

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 […]
  • 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 […]
  • Turn off unneeded services on your Linux machineTurn off unneeded services on your Linux machine One of the easiest ways to start securing your server (and speeding it up) is to turn off unnecessary services that are usually running by default. This little script will go through and […]
  • Install CSF/LFD Firewall on your Linux Server The first thing on your mind when setting up a new Linux server (dedicated or VPS) is how you can increase security.  One of the best tools in your bag of tricks should be the CSF […]
  • 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="">