Block Countries from your server easily with CSF

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!