239 字
1 分钟
安装fail2ban防御网络攻击
安装nginx
| 步骤 | 命令 |
|---|---|
| 1.更新软件列表 | apt update |
| 2.安装fail2ban和依赖 | apt install -y fail2ban rsyslog |
| 3.启动rsyslog(ssh记录日志需要它) | systemctl start rsyslog |
| 4.开机自启 | systemctl enable rsyslog |
| ⭐配置文件位置 | /etc/fail2ban |
| 5.启动fail2ban | systemctl start fail2ban |
| 6.重启fail2ban | systemctl restart fail2ban |
| 7.开机自启 | systemctl enable fail2ban |
| 8.取消开机自启 | systemctl disable fail2ban |
| ---------------------------------- | ------------------------------------- |
| 查看封禁列表 | fail2ban-client status sshd |
| 解封命令 | fail2ban-client set sshd unbanip 8.8.8.8 |
配置文件解析
/etc/fail2ban/jail.local
配置文件,开启或关闭某一项防御都写在里面。
/etc/fail2ban/jail.d/*
配置文件,作用和jail.local相同,但优先级更高,并且文件夹里可以拆分成多个文件,方便管理。
/etc/fail2ban/jail.conf
这是默认配置文件,优先级低于手动创建的 /etc/fail2ban/jail.local ,所以一般不修改它,只将它当作配置模板。
/etc/fail2ban/filter.d/*
监狱:也就是匹配规则,文件名即是监狱名称,支持正则表达式,安装时自带,也可自行编写或者修改。
安装fail2ban防御网络攻击
https://www.pidexe.com/posts/fail2ban/