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!
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.
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.
thank u for this usefull information, it helped me alot
nice article.thanks a lot