AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 422339
Accepted
THpubs
THpubs
Asked: 2012-08-29 23:00:12 +0800 CST2012-08-29 23:00:12 +0800 CST 2012-08-29 23:00:12 +0800 CST

Fail2Ban 添加了 iptable 规则但它们不起作用?

  • 772

Fail2Ban 刚刚阻止了我的 IP 3 次 SSH 尝试。它添加了 iptables 规则,我可以使用“sudo iptables -L -n”命令查看它。但是我仍然可以访问该站点并通过 SSH 登录!可能是什么问题?是因为我在使用 CloudFlare 吗?我已将 Nginx 设置为将真实 IP 写入访问日志而不是 Cloud Flare IP。还不够吗?

Chain fail2ban-ssh (1 references)
 target     prot opt source               destination         
 DROP       all  --  119.235.14.8         0.0.0.0/0           
 RETURN     all  --  0.0.0.0/0            0.0.0.0/0  

输入链:

Chain INPUT (policy DROP)

    target     prot opt source               destination         
    fail2ban-NoAuthFailures  tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80
    fail2ban-nginx-dos  tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 80,8090
    fail2ban-postfix  tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 25,465
    fail2ban-ssh-ddos  tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 22
    fail2ban-ssh  tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 22
    ufw-before-logging-input  all  --  0.0.0.0/0            0.0.0.0/0           
    ufw-before-input  all  --  0.0.0.0/0            0.0.0.0/0           
    ufw-after-input  all  --  0.0.0.0/0            0.0.0.0/0           
    ufw-after-logging-input  all  --  0.0.0.0/0            0.0.0.0/0           
    ufw-reject-input  all  --  0.0.0.0/0            0.0.0.0/0           
    ufw-track-input  all  --  0.0.0.0/0            0.0.0.0/0           
    LOG        all  --  0.0.0.0/0            0.0.0.0/0            LOG flags 0 level 4
fail2ban
  • 1 1 个回答
  • 1997 Views

1 个回答

  • Voted
  1. Best Answer
    Charles Chou
    2012-11-08T20:51:37+08:002012-11-08T20:51:37+08:00

    更新 2019:原始答案中的 API 使用已被弃用,取而代之的是 API v4,请改用新版本。 Fail2ban unban 操作因 Cloudflare 而失败,感谢 @baptx 评论

    iptables获取不到真实ip,所以应该使用cloudflare的api将云端的IP加入黑名单。

    这是我的动作配置文件

    # Fail2Ban configuration file
    #
    # Author: Charles Chou
    # Modified: Norman Yee 
    #           fix original cloudflare-blacklist.conf
    
    # $Revision$
    #
    
    [Definition]
    
    # Option:  actionstart
    # Notes.:  command executed once at the start of Fail2Ban.
    # Values:  CMD
    #
    actionstart =
    
    # Option:  actionstop
    # Notes.:  command executed once at the end of Fail2Ban
    # Values:  CMD
    #
    actionstop =
    
    # Option:  actioncheck
    # Notes.:  command executed once before each actionban command
    # Values:  CMD
    #
    actioncheck =
    
    # Option:  actionban
    # Notes.:  command executed when banning an IP. Take care that the
    #          command is executed with Fail2Ban user rights.
    # Tags:    <ip>  IP address
    #          <failures>  number of failures
    #          <time>  unix timestamp of the ban time
    # Values:  CMD
    #
    actionban = curl -s "https://www.cloudflare.com/api.html?a=ban&key=<ip>&u=<account>&tkn=<token>"
    
    # Option:  actionunban
    # Notes.:  command executed when unbanning an IP. Take care that the
    #          command is executed with Fail2Ban user rights.
    # Tags:    <ip>  IP address
    #          <failures>  number of failures
    #          <time>  unix timestamp of the ban time
    # Values:  CMD
    #
    actionunban = curl -s "https://www.cloudflare.com/api.html?a=nul&key=<ip>&u=<account>&tkn=<token>"
    
    [Init]
    
    # Option:  account
    # Notes.:  In the actionban and actionunban sections,replace CLOUDFLARE_LOGIN with your CloudFlare login email
    # Values:  your CloudFlare account
    #
    account = [email protected]
    
    # Option:  token
    # Notes.:  In the actionban and actionunban sections, replace CLOUDFLARE_API_TOKEN with your API key
    # Values:  Your CloudFlare API key 
    #
    token = Your API key here
    
    
    • 4

相关问题

  • 任何非自定义的方式来管理使用 fail2ban 和 libvirt+kvm 的 iptables?

  • Denyhosts vs fail2ban vs iptables - 防止暴力登录的最佳方法?

  • 用户是否有任何正当理由请求 phpinfo()

  • 将 Fail2ban 配置为忽略本地 (NAT) IP

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve