- Instalação
- Configuração
- Considerações
- Desinstalar CSF
1. Instalação
yum install perl-libwww-perl -y
cd /usr/src
wget https://download.configserver.com/csf.tgz
tar xzf csf.tgz
cd csf
sh install.sh
perl /usr/local/csf/bin/csftest.plO resultado do último comando deve ser próximo a esse
Testing ip_tables/iptable_filter...OK
Testing ipt_LOG...OK
Testing ipt_multiport/xt_multiport...OK
Testing ipt_REJECT...OK
Testing ipt_state/xt_state...OK
Testing ipt_limit/xt_limit...OK
Testing ipt_recent...OK
Testing xt_connlimit...OK
Testing ipt_owner/xt_owner...OK
Testing iptable_nat/ipt_REDIRECT...OK
Testing iptable_nat/ipt_DNAT...OK
**RESULT: csf should function on this server**Agora efetuaremos a desativação do firewalld
systemctl stop firewalld
systemctl disable firewalldCaso os comandos de instalação CSF não funcionem
yum install perl
yum install perl-libwww-perl net-tools perl-LWP-Protocol-https -y2. Instalação
Efetue os ajustes no arquivo /etc/csf/csf.conf, as configurações básicas que devem ficar são
# Testing flag - enables a CRON job that clears iptables incase of
# configuration problems when you start csf. This should be enabled until you
# are sure that the firewall works - i.e. incase you get locked out of your
# server! Then do remember to set it to 0 and restart csf when you're sure
# everything is OK. Stopping csf will remove the line from /etc/crontab
#
# lfd will not start while this is enabled
TESTING = "0"
# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995"
# Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,53,80,110,113,443,587,993,995"Por fim, execute o comando de automatização do inicio e inicie o serviço também.
systemctl restart {csf,lfd}
systemctl enable {csf,lfd}
systemctl is-active {csf,lfd}
csf -v3. Considerações
Como liberar IP:
csf -aComo bloquear IP:
csf -dLimitando conexões de entrada por porta
Abra o arquivo /etc/csf/csf.conf e localize a opção abaixo:
CONNLIMIT = ” “
Você pode limita as conexões a partir do comando abaixo, considerando que estamos usando como exemplo a porta 22 para até 2 conexões. CONNLIMIT = “22; 2”
Bloquear países menos seguro, localize o arquivo de configuração em /etc/csf/csf.conf, e posteriormente procure pela opção CC_DENY, adicione a linha abaixo no campo.
AA,AC,AE,AF,AG,AJ,AL,AM,AN,AO,AQ,AR,AS,AT,AU ,AV,AX,AY,AZ,BA,BB,BC,BD,BE,BF,BGBH,BK,BL,BM,BN,BO,BP,BQ,BT,BU,BV,BX,BY,CA,CB,CD,CE,CF,CG,CH,CL,CJ,CK,CM,CN,CO,CQ,CR,CS,CT,CU,CV,CW,CY,CZ,DA,DJ,DO,DQ,DR,DX,EC,EG ,EI,EK,EN,ER,ES,ET,EZ,FG,FI,FJ,FK,FM,FO,FP,FQ,FR,FS,GA,GB,GF,GG,GH,GI,GJ,GK,GL,GM,GP,GQ,GR,GT,GV,GW,GY,GZ,HA,HK,HM,HO,HQ,HR,HU,IC,ID,IM,IN,IO,IP,IR,IS,IT,CI,IZ,JP,JE,JM,JN,JO,JQ,KE,KG,KN,KQ,KR,KS,KT,KU,KV,LA,LE,LG,LH,LI,LO,LP,LQ,LS,LT,LU,LY,MA,MB,MC,MD,ME,MF,MG,MH,MI,MJ,MK,ML,MN,MP,MQ,MR,MT,MU,MV,MX,MY,MZ,NC,NE,NF,NG,NH,NI,NL,NO,NP,NR,NS,NT,NU,NZ,PA,PC,PE,PF,PG,PK,PL,PM,PT,PP,PS,QA,PU,RE,RI,RM,RN,RO,RP,RQ,RS,RW,SA,SB,SC,SE,SF,SG,SH,SI,SL,SM,SN,SO,SP,ST,SU,SV,SW,SX,SY,SZ,TB,TD,TH,TI,TK,TL,TN,TO,TP,TS,TT,TR,TV,TW,TX,TZ,UG,UK,UP,UV,UY,UZ,VC,VE,VI,VM,VQ,VT,WA,WE,WF,WI,WQ,WS,WZ,YM,ZA,ZI4. Desinstalar CSF
Para desinstalação do CSF é simples, execute o comando abaixo:
/etc/csf/uninstall.sh