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:
1
|
CC_DENY = “”
|
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:
1
|
CC_DENY = “RU,CN”
|
Then, just restart CSF!
1
|
csf –r
|
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!