Для моей версии (1.8.25.0) вопрос решался так:
Ищем такие строки:
if (res < 0) { /* Something failed in authentication */
ast_log(LOG_NOTICE, "Failed to authenticate device %s\n", get_header(req, "From"));
transmit_response(p, "403 Forbidden", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
return 0;
}
if (res < 0) { /* Something failed in authentication */
ast_log(LOG_NOTICE, "Failed to authenticate device %s\n", get_header(req, "From"));
transmit_response_reliable(p, "403 Forbidden", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
res = 0;
goto request_invite_cleanup;
}
и меняем на:
if (res < 0) { /* Something failed in authentication */
ast_log(LOG_NOTICE, "Failed to authenticate device %s [IP: %s]\n", get_header(req, "From"), ast_sockaddr_stringify(addr));
transmit_response(p, "403 Forbidden", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
return 0;
}
if (res < 0) { /* Something failed in authentication */
ast_log(LOG_NOTICE, "Failed to authenticate device %s [IP: %s]\n", get_header(req, "From"), ast_sockaddr_stringify(addr));
transmit_response_reliable(p, "403 Forbidden", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
res = 0;
goto request_invite_cleanup;
}
в fail2ban добавляем регулярное выражение в failregex
NOTICE.* .*: Failed to authenticate device .* \[IP: <HOST>.*\]
В баню отправляются =)