centos:
yum -y install epel-release
yum -y install fail2ban-firewalld
debian/ubuntu:
apt install fail2ban -y
加入开机启动
systemctl enable fail2ban
立即启动
systemctl start fail2ban
查看状态
systemctl status fail2ban -l
查看jail状态
fail2ban-client status
配置文件:/etc/fail2ban/jail.local
注意[DEFAULT]表示全局规则,但是分类有设置将大于全局规则

[DEFAULT]
ignoreip = 127.0.0.1/8白名单IP
bantime = 7200#被封IP禁止2小时内登录
findtime = 600 #10分钟内输错3次密码,激活fail2ban,封禁IP

maxretry = 3 #输错3次
banaction = firewallcmd-ipset#屏蔽IP所使用的方法
action = %(action_mwl)s #禁IP+写入日志
[sshd]
enabled = true#启用
filter = sshd #规则名称,sshd是fail2ban内置规则
port = 22 #SSH连接端口
action = %(action_mwl)s
logpath = /var/log/secure

查看黑名单语法
fail2ban-client status 名称
例查看sshd
fail2ban-client status sshd
删除黑名单语法
fail2ban-client set 名称 unbanip IP地址
例删除sshd的黑名单192.168.0.5
fail2ban-client set sshd unbanip 192.168.0.15

分类: Fail2Ban 标签: 暂无标签

评论

暂无评论数据

暂无评论数据

目录