Fail2ban服务器手动解绑ip及添加黑白名单IP

Fail2ban是有用的应用程序,可以保护您的服务器免受暴力攻击,读取应用程序日志和被检测为攻击者的禁止IP。

Fail2ban是一个暂时或永久禁止IP的程序,您还可以将白名单中的特定IP地址列入白名单,以便它们不会被fail2ban阻止。

查看封禁IP

iptables -nL
检查fail2ban状态(会显示处当前活动的监狱列表)
fail2ban-client status
检查一份特定的监狱状态(iredmail 一般就是网页访问一般就是 roundcube)
fail2ban-client status postfix

手动解ban

比如说是roundcube服务

fail2ban-client set roundcube unbanip 141.98.11.68

什么服务set什么,可以iptables -nL列出,比如iRedmail搭建的邮件系统,那postfix的服务/规则名就叫做postfix-iredmail,解封的时候就执行

fail2ban-client set postfix-iredmail unbanip 1.2.3.4

白名单IP

编辑/etc/fail2ban/jail.local

有一行ignoreip,在末尾加上自己的IP即可,注意用空格分开

[DEFAULT]
# time is in seconds. 3600 = 1 hour, 86400 = 24 hours (1 day)
findtime = 3600 ## 密码输入时间限制
bantime = 3600 ## IP 禁止访问时间
maxretry = 5 #最大重试次数
ignoreip = 127.0.0.1 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 1.2.3.4 ## 忽略本地 IP

重启fail2ban服务

systemctl restart fail2ban.service