Pessoal,<div><br></div><div>Segui esse tutorial, porém ainda aparentemente ainda não está funcionando o Fail2ban</div><div><br></div><div><br></div><div>##########################################################################</div>
<div><br></div><div><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)"><strong>Configurando o Fail2Ban</strong></p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Agora nós precisamos fazer com que o fail2ban seja capaz de identificar ataques contra o asterisk.</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Os arquivos de configuração ficam em:<strong> /etc/fail2ban/filter.d</strong></p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Vamos criar aqui um arquivo para o asterisk.</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
#touch asterisk.conf</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Este arquivo deve conter o seguinte:</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">[INCLUDES]</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
[Definition]<br>failregex = NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – Wrong password<br> NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – No matching peer found<br> NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – Username/auth name mismatch<br>
NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – Device does not match ACL<br> NOTICE.* <HOST> failed to authenticate as ‘.*’$<br> NOTICE.* .*: No registration for peer ‘.*’ \(from <HOST>\)<br>
NOTICE.* .*: Host <HOST> failed MD5 authentication for ‘.*’ (.*)<br> NOTICE.* .*: Failed to authenticate user .*@<HOST>.*<br>ignoreregex =</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
No aquivo<strong> /etc/fail2ban/jail.conf</strong> inclua as seguintes linhas:</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
[asterisk-iptables]</p><p style="font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px"><span style="color:rgb(65,65,65);background-color:rgb(244,244,244)">enabled = true<br>
filter = asterisk<br>action = iptables-allports[name=ASTERISK, protocol=all]<br> sendmail-whois[name=ASTERISK, dest=root, sender=</span><span style="background-color:rgb(255,255,255)"><font color="#ff0000"><a href="mailto:alclicio@gmail.com">alclicio@gmail.com</a></font></span><span style="background-color:rgb(244,244,244)"><font color="#414141">] #</font><font color="#ff0000">aqui devo colocar meu email ?</font></span><br>
<span style="color:rgb(65,65,65);background-color:rgb(244,244,244)">logpath = /var/log/asterisk/full</span><br><span style="color:rgb(65,65,65);background-color:rgb(244,244,244)">maxretry = 3</span><br><span style="color:rgb(65,65,65);background-color:rgb(244,244,244)">bantime = 259200</span><br>
<strong style="color:rgb(65,65,65);background-color:rgb(244,244,244)">Maxretry </strong><span style="color:rgb(65,65,65);background-color:rgb(244,244,244)">determina a quantidade de erros que o fail2ban vai aceitar de um determinado host antes de bani-lo.</span></p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)"><strong>O</strong> <strong>bantime</strong> é em segundos, portanto neste caso qualquer tentativa de ataque ao asterisk será banida por 72 horas.</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Para não banir você mesmo, no jail.conf, procure pela tag [DEFAULT], no paramento ignoreip informe seu ip.</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Edite o <strong>/etc/asterisk/logger.conf</strong> e defina o dateformat da seguinte forma.</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)"> [general]<br>dateformat=%F %T</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
Na sessão [logfiles] você deve inserir a seguinte linha:</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
syslog.local0 => notice</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Feito isso é só dar reload no logger</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">asterisk -rx ”logger reload”</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
Para verificar se o fail2ban subiu, basta rodar o seguinte comando:</p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">
<strong>iptables -L -v</strong></p><p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">As seguintes linhas devem aparecer:</p>
<p style="color:rgb(65,65,65);font-family:'Lucida Sans Unicode',Arial,Helvetica,sans-serif;font-size:11px;line-height:19px;background-color:rgb(244,244,244)">Chain fail2ban-ASTERISK (1 references)<br> pkts bytes target prot opt in out source destination<br>
6287K 1158M RETURN all – any any anywhere anywhere</p></div><div><br clear="all"><div>Estou configurando no elastix 2.3.0, tem algo a mais a fazer? tentei autenticar um ramal externo com a senha errada por mais de 3 vezes e ainda não está banindo.</div>
<div><br></div>-- <br>ALCLICIO VIEIRA,<br>ITIL® V3 Certification,<br>Crea-DF 10476 Telecom<br><br><div><span style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">Phone:55 </span><a value="+551140633631" style="color:rgb(0,0,204);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">(11) 3509-2505</a><span style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)"> - São Paulo</span><br style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">
<span style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">Phone</span><span style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">:55 </span><a value="+556140638362" style="color:rgb(0,0,204);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">(61) 4063-7110</a><span style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)"> - Brasília</span><br style="color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px;background-color:rgb(255,255,255)">
<div><span style="background-color:rgb(255,255,255);color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px">Phone</span><span style="background-color:rgb(255,255,255);color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px">:55 </span><a value="+558540628362" style="background-color:rgb(255,255,255);color:rgb(0,0,204);font-family:Arial,sans-serif;line-height:16px">(62) 3416-7800 </a><span style="background-color:rgb(255,255,255);color:rgb(0,64,128);font-family:Arial,sans-serif;line-height:16px">- Goiás</span> <br>
<div><div><br><br></div></div></div></div><br>
</div>