How to block countries accessing server using csf?

Is it possible to block countries from server using CSF?

Yeah, It is very easy to block countries on your server by using an csf (Config server firewall). There is an option in the csf to block IP range from different countries.

Config Server Firewall is abbreviated as CSF. CSf is the most commonly using firewall application to secure Linux servers. CSF has wide range of options to manage Linux firewall via comman-line and from the control panel.

CSF helps to configure server firewall easily and simply.

csf-block

How to block countries in csf?

In the csf configuration file (/etc/csf/csf.conf), there is an option to block/allow access from an IP range by using country code. Here I’m going to explain how to allow or deny IP range using this feature.

For allowing a country to your server you can use the directive ‘CC_ALLOW‘ from the csf configuration file.

CC_ALLOW = ""

Similerly you can deny by using the directive ‘CC_DENY

CC_DENY = ""

Each option is a comma separated list of CC’s, e.g. “US,GB,DE”

You need to restart the csf service to get the changes to be worked. Run the following command for restarting the csf service.

csf -r

Refer this link for Other useful csf command

Country codes:

AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BT,BO,BA,BW,BV,BR,IO,BN,BG,BF,BI,KH,CM,CA,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CD,CK,CR,CI,HR,CU,CY,CZ,DK,DJ,DM,DO,TP,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,FX,GF,PF,TF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,VA,HN,HK,HU,IS,IN,ID,IR,IQ,IE,IL,IT,JM,JP,JO,KZ,KE,KI,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,RU,RW,KN,LC,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,ES,LK,SH,PM,SD,SR,SJ,SZ,SE,CH,SY,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,GB,US,UM,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,ZM,ZW

Refer this link for more details : Allocation of IP addresses by Country

That’s it..

Related links

Install and configure csf on CentOS
CSF commands for Unix/Linux servers
Csf command not found in WHM/cPanel server

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

5 Responses

  1. Robin says:

    Can i use a * for all counters and onley fill in the allow part of countries that are allowed?

  2. HR Yadav says:

    Searching from long time, finally find this, thanks for sharing important information.

  1. December 24, 2013

    […] Related links: Install and configure csf on CentOS CSF commands for Unix/Linux servers Process tracking with the help of csf How to disable Lfd excessive resource usage alert How to block countries from server by using csf […]

  2. December 27, 2013

    […] CSF commands for Unix/Linux servers How to find whether the IP address is blacklisted or not in CSF How to block countries from server by using csf How to disable Lfd excessive resource usage alert Process tracking with the help of […]

Leave a Reply

Your email address will not be published. Required fields are marked *