Asterisk 13.x和fail2ban正则表达式字符串
创始人
2024-09-20 19:30:41
0

要解决"Asterisk 13.x和fail2ban正则表达式字符串"的问题,您可以按照以下步骤进行操作:

步骤1:安装和配置fail2ban

  1. 在您的系统上安装fail2ban。可以使用以下命令之一,具体取决于您使用的操作系统:

    • Ubuntu/Debian:sudo apt-get install fail2ban
    • CentOS/RHEL:sudo yum install fail2ban
  2. 安装完成后,进入fail2ban的配置目录。通常情况下,该目录位于/etc/fail2ban/。

  3. 编辑jail.local配置文件。使用编辑器打开该文件,例如:

    • sudo nano /etc/fail2ban/jail.local
  4. 在文件的末尾添加以下内容,以配置Asterisk 13.x的fail2ban过滤器:

    [asterisk-iptables]
    enabled = true
    filter = asterisk
    action = iptables-allports[name=ASTERISK, protocol=all]
             sendmail-whois[name=ASTERISK, dest=youremail@example.com, sender=fail2ban@example.com, sendername="Fail2Ban"]
    logpath = /var/log/asterisk/messages
    maxretry = 5
    bantime = 86400
    
  5. 保存并关闭文件。

  6. 创建fail2ban的Asterisk过滤器。在同一目录中,创建一个名为"asterisk.conf"的文件,并将以下内容复制到文件中:

    [Definition]
    failregex = NOTICE.* .*: Registration from '.*' failed for '' - Wrong password
                NOTICE.* .*: Registration from '.*' failed for '' - No matching peer found
                NOTICE.* .*: Registration from '.*' failed for '' - Username/auth name mismatch
                NOTICE.* .*: Registration from '.*' failed for '' - Device does not match ACL
                NOTICE.* .*: Registration from '.*' failed for '' - Peer is not supposed to register
                NOTICE.* .*: Registration from '.*' failed for '' - ACL error \(permit\)
                NOTICE.* .*: Registration from '.*' failed for '' - No matching peer found
                NOTICE.* .*: Call from '.*' \(\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}\) to extension '.*' rejected because extension not found in context
                NOTICE.* .*: Call from '.*' \(\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}\) to extension '.*' rejected because extension not found in context '.*'
                NOTICE.* .*: Host  failed to authenticate as '.*'$
    ignoreregex =
    
  7. 保存并关闭文件。

  8. 重新启动fail2ban服务,以使更改生效。使用以下命令之一,具体取决于您使用的操作系统:

    • Ubuntu/Debian:sudo service fail2ban restart
    • CentOS/RHEL:sudo systemctl restart fail2ban

步骤2:测试fail2ban配置

  1. 打开Asterisk的日志文件/var/log/asterisk/messages。

  2. 通过在Asterisk服务器上发起一些恶意登录尝试,来测试fail2ban是否正常工作。

  3. 在测试完成后,检查fail2ban的日志文件/var/log/fail2ban.log,以确保fail2ban已经成功地禁止了恶意IP地址。

通过按照上述步骤进行操作,您将能够成功配置和使用fail2ban来保护Asterisk服务器免受恶意登录尝试。

相关内容

热门资讯

线上(wepoke真的)原来是... 线上(wepoke真的)原来是真的有挂!其实真的有挂(2022已更新)(哔哩哔哩);亲,其实确实真的...
两教程(Wepoke程序)软件... 两教程(Wepoke程序)软件透明挂辅助工具(软件透明挂)透视辅助(2024已更新)(哔哩哔哩);致...
软件(wepoke透明)原来是... 软件(wepoke透明)原来是真的有挂!其实真的有挂(2020已更新)(哔哩哔哩)是一款可以让一直输...
一模拟器(德扑工具)外挂辅助工... 一模拟器(德扑工具)外挂辅助工具(透视)透视辅助(2025已更新)(哔哩哔哩);亲真的是有正版授权,...
系统(aapoker讲解)竟然... 系统(aapoker讲解)竟然真的有挂!其实真的有挂(2021已更新)(哔哩哔哩);aapoker讲...
6系统(aapoker下载)外... 6系统(aapoker下载)外挂辅助工具(辅助挂)透视辅助(2023已更新)(哔哩哔哩)aapoke...
智能(德扑之星刷数据)果真真的... 智能(德扑之星刷数据)果真真的有挂!原来真的有挂(2025已更新)(哔哩哔哩);《WPK辅助透视》‌...
1机器人(德州nzt软件)软件... 1机器人(德州nzt软件)软件透明挂辅助软件(透视)透视辅助(2022已更新)(哔哩哔哩);人气非常...
ai代打(德扑之星决策)确实是... ai代打(德扑之星决策)确实是真的有挂!原来真的有挂(2020已更新)(哔哩哔哩);科技详细教程小薇...
第8透明(wepoke数据)外... 第8透明(wepoke数据)外挂透明挂辅助神器(辅助挂)透视辅助(2023已更新)(哔哩哔哩);原来...