V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
finab
V2EX  ›  问与答

fail2ban 经常出现漏 BAN IP 的情况,有没有彦祖来诊断一下

  •  
  •   finab · 1 天前 · 623 次点击

    具体情况是可以在 Banned IP list 里看到一些 IP 已经被 BAN ,但不在 ipset 里。

    导致这些 ip 一直可以持续访问,fail2ban 识别到后触发 BAN Action ,但由于这些 IP 已存在 Banned IP list , 于是重复提示 already banned ,却不会往 ipset 添加对应 IP 封禁掉。

    Ubuntu 20.04.6 LTS, Fail2Ban v0.11.1

    Filter:

    [Definition]
    failregex = ^<HOST> .* "POST .*HTTP.*" 405 .*$
    ignoreregex =  #.*(robots.txt|favicon.ico|jpg|png)
    

    jail.local:

    [DEFAULT]
    banaction = iptables-ipset-proto6
    banaction_allports = iptables-ipset-proto6-allports
    
    [nginx-req-405]
    enabled = true
    port = http,https
    filter = nginx-req-405
    logpath = /var/log/nginx/hello.log
    maxretry = 5
    findtime = 5m
    bantime = 24h
    

    其他都是默认配置没有修改。

    4 条回复    2025-11-19 18:06:00 +08:00
    defunct9
        1
    defunct9  
       1 天前
    开 ssh ,让我上去看看
    ryd994
        2
    ryd994  
       1 天前 via Android
    改成非标端口+公钥验证+禁止密码验证,就彻底安静了
    还可以再进一步:cloudflare zero trust tunnel ,连公网 IP 都没有,彻底杜绝
    busier
        3
    busier  
       1 天前 via iPhone
    ipset 表大小有配置限制的 看下 ipset 是否限制太小

    具体将你 ipset 的顶部配置喂给 ai 看看
    shcsc
        4
    shcsc  
       2 小时 35 分钟前
    @defunct9 还是好人多
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3164 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 12:41 · PVG 20:41 · LAX 04:41 · JFK 07:41
    ♥ Do have faith in what you're doing.