下载和安装
安装过程中如果报错,需要额外安装sendmail:sendmail.zip
使用
创建配置
vi /etc/fail2ban/jail.local
配置内容
[DEFAULT]
ignoreip = 127.0.0.1/8
bantime = 86400
findtime = 600
maxretry = 5
banaction = firewallcmd-ipset
action = %(action_mwl)s
[sshd]
enabled = true
filter = sshd
port = 22
action = %(action_mwl)s
logpath = /var/log/secure
配置说明:如果同一个IP,在10分钟内,如果连续超过5次错误,则使用Firewalld将IP禁用600秒。
其中/var/log/secure为日志内容,可进行观察。
findtime:在某某时间内进行判断,秒
maxretry:错误次数
ignoreip:ip白名单,多个,号分割
bantime:禁止持续时间,秒
banaction:使用的方式,用Firewalld防火墙,此外还可以用iptables防火墙
启动或重新启动,使配置生效
systemctl restart fail2ban
参考
https://blog.csdn.net/qq_58996293/article/details/135216040
https://cloud.tencent.com/developer/article/2372157