How to Block Traffic by Country in the CSF Firewall

How to Block Traffic by Country in the CSF Firewall

In this tutorial I will show you, how to block Traffic by Country in the CSF Firewall.

If you don’t have a need for certain international visitors to your Linux server, It is very easy to block countries on your server by using an csf (Config server firewall). There is an option on your csf to block IP range from different countries. You can follow our guide on installing csf If csf is not install.

See Also:

Block Countries using CSF Firewall

In your csf configuration file there is an option to block/allow access from an IP range by using country code. For allowing a country to your server you can use the directive ‘CC_ALLOW‘ from the csf configuration file.

# vim /etc/csf/csf.conf
CC_ALLOW = ""

Similerly you can deny by using the directive ‘CC_DENY‘

CC_DENY = "RU,CN"

In above Example I have blocked China and Russia.

Then, just restart CSF

# csf -r

List of Internet Country Codes

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

 
Enjoyed this video?
How to Block Traffic by Country in the CSF Firewall
"No Thanks. Please Close This Box!"