如何在 CentOS 6/7 上移除被 Fail2ban 禁止的 IP

如何在 CentOS 6/7 上移除被 Fail2ban 禁止的 IP

fail2ban 是一款用于保护你的服务器免于暴力攻击的入侵保护软件。fail2ban 用 Python 写成,并广泛用于很多服务器上。fail2ban 会扫描日志文件和 IP 黑名单来显示恶意软件、过多的密码失败尝试、web 服务器利用、wordpress 插件攻击和其他漏洞。如果你已经安装并使用了 fail2ban 来保护你的 web 服务器,你也许会想知道如何在 CentOS 6、CentOS 7、RHEL 6、RHEL 7 和 Oracle Linux 6/7 中找到被 fail2ban 阻止的 IP,或者你想将 ip 从 fail2ban 监狱中移除。

如何列出被禁止的 IP

要查看所有被禁止的 ip 地址,运行下面的命令:

  1. <span class="com">#</span><span class="pln"> iptables </span><span class="pun">-</span><span class="pln">L</span>
  2. <span class="typ">Chain</span><span class="pln"> INPUT </span><span class="pun">(</span><span class="pln">policy ACCEPT</span><span class="pun">)</span>
  3. <span class="pln">target prot opt source destination</span>
  4. <span class="pln">f2b</span><span class="pun">-</span><span class="typ">AccessForbidden</span><span class="pln"> tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  5. <span class="pln">f2b</span><span class="pun">-</span><span class="typ">WPLogin</span><span class="pln"> tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  6. <span class="pln">f2b</span><span class="pun">-</span><span class="typ">ConnLimit</span><span class="pln"> tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  7. <span class="pln">f2b</span><span class="pun">-</span><span class="typ">ReqLimit</span><span class="pln"> tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  8. <span class="pln">f2b</span><span class="pun">-</span><span class="typ">NoAuthFailures</span><span class="pln"> tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  9. <span class="pln">f2b</span><span class="pun">-</span><span class="pln">SSH tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="kwd">ssh</span>
  10. <span class="pln">f2b</span><span class="pun">-</span><span class="pln">php</span><span class="pun">-</span><span class="pln">url</span><span class="pun">-</span><span class="pln">open tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  11. <span class="pln">f2b</span><span class="pun">-</span><span class="pln">nginx</span><span class="pun">-</span><span class="pln">http</span><span class="pun">-</span><span class="pln">auth tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere multiport dports http</span><span class="pun">,</span><span class="pln">https</span>
  12. <span class="pln">ACCEPT all </span><span class="pun">--</span><span class="pln"> anywhere anywhere state RELATED</span><span class="pun">,</span><span class="pln">ESTABLISHED</span>
  13. <span class="pln">ACCEPT icmp </span><span class="pun">--</span><span class="pln"> anywhere anywhere</span>
  14. <span class="pln">ACCEPT all </span><span class="pun">--</span><span class="pln"> anywhere anywhere</span>
  15. <span class="pln">ACCEPT tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="typ">EtherNet</span><span class="pun">/</span><span class="pln">IP</span><span class="pun">-</span><span class="lit">1</span>
  16. <span class="pln">ACCEPT tcp </span><span class="pun">--</span><span class="pln"> anywhere anywhere tcp dpt</span><span class="pun">:</span><span class="pln">http</span>
  17. <span class="pln">REJECT all </span><span class="pun">--</span><span class="pln"> anywhere anywhere reject</span><span class="pun">-</span><span class="kwd">with</span><span class="pln"> icmp</span><span class="pun">-</span><span class="pln">host</span><span class="pun">-</span><span class="pln">prohibited</span>
  18. <span class="typ">Chain</span><span class="pln"> FORWARD </span><span class="pun">(</span><span class="pln">policy ACCEPT</span><span class="pun">)</span>
  19. <span class="pln">target prot opt source destination</span>
  20. <span class="pln">REJECT all </span><span class="pun">--</span><span class="pln"> anywhere anywhere reject</span><span class="pun">-</span><span class="kwd">with</span><span class="pln"> icmp</span><span class="pun">-</span><span class="pln">host</span><span class="pun">-</span><span class="pln">prohibited</span>
  21. <span class="typ">Chain</span><span class="pln"> OUTPUT </span><span class="pun">(</span><span class="pln">policy ACCEPT</span><span class="pun">)</span>
  22. <span class="pln">target prot opt source destination</span>
  23. <span class="typ">Chain</span><span class="pln"> f2b</span><span class="pun">-</span><span class="typ">NoAuthFailures</span><span class="pun">(</span><span class="lit">1</span><span class="pln"> references</span><span class="pun">)</span>
  24. <span class="pln">target prot opt source destination</span>
  25. <span class="pln">REJECT all </span><span class="pun">--</span><span class="lit">64.68</span><span class="pun">.</span><span class="lit">50.128</span><span class="pln"> anywhere reject</span><span class="pun">-</span><span class="kwd">with</span><span class="pln"> icmp</span><span class="pun">-</span><span class="pln">port</span><span class="pun">-</span><span class="pln">unreachable</span>
  26. <span class="pln">REJECT all </span><span class="pun">--</span><span class="lit">104.194</span><span class="pun">.</span><span class="lit">26.205</span><span class="pln"> anywhere reject</span><span class="pun">-</span><span class="kwd">with</span><span class="pln"> icmp</span><span class="pun">-</span><span class="pln">port</span><span class="pun">-</span><span class="pln">unreachable</span>
  27. <span class="pln">RETURN all </span><span class="pun">--</span><span class="pln"> anywhere anywhere</span>

如何从 Fail2ban 中移除 IP

  1. <span class="com">#</span><span class="pln"> iptables </span><span class="pun">-</span><span class="pln">D f2b</span><span class="pun">-</span><span class="typ">NoAuthFailures</span><span class="pun">-</span><span class="pln">s banned_ip </span><span class="pun">-</span><span class="pln">j REJECT</span>

我希望这篇教程可以给你在 CentOS 6、CentOS 7、RHEL 6、RHEL 7 和 Oracle Linux 6/7 中移除被禁止的 ip 一些指导。


via: http://www.ehowstuff.com/how-to-remove-banned-ip-from-fail2ban-on-centos/

作者:skytech 译者:geekpi 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关推荐