V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
finab
V2EX  ›  问与答

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

  •  
  •   finab · Nov 18, 2025 · 1565 views
    This topic created in 171 days ago, the information mentioned may be changed or developed.

    具体情况是可以在 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 replies    2025-11-19 18:06:00 +08:00
    defunct9
        1
    defunct9  
       Nov 18, 2025
    开 ssh ,让我上去看看
    ryd994
        2
    ryd994  
       Nov 18, 2025 via Android
    改成非标端口+公钥验证+禁止密码验证,就彻底安静了
    还可以再进一步:cloudflare zero trust tunnel ,连公网 IP 都没有,彻底杜绝
    busier
        3
    busier  
       Nov 18, 2025 via iPhone
    ipset 表大小有配置限制的 看下 ipset 是否限制太小

    具体将你 ipset 的顶部配置喂给 ai 看看
    shcsc
        4
    shcsc  
       Nov 19, 2025
    @defunct9 还是好人多
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1251 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 17:37 · PVG 01:37 · LAX 10:37 · JFK 13:37
    ♥ Do have faith in what you're doing.