前言
如果你的服务器暴露在互联网上,每天可能会遭受数千次的暴力破解攻击。本文将介绍几款实用的免费开源安全工具,帮助你保护服务器安全。
一、Fail2ban - 基础防护利器
什么是 Fail2ban?
Fail2ban 是一款入侵防御软件,通过监控系统日志文件,自动封禁多次登录失败的 IP 地址,有效防止暴力破解攻击。
安装 Fail2ban
Ubuntu/Debian:
bash
sudo apt update
sudo apt install fail2ban -y
CentOS/RHEL:
bash
sudo yum install epel-release -y
sudo yum install fail2ban -y
基础配置
- 创建本地配置文件(不要直接修改默认配置):
bash
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
- 配置 SSH 保护:
ini
[DEFAULT]
# 封禁时间(秒)
bantime = 3600
# 查找时间窗口(秒)
findtime = 600
# 最大重试次数
maxretry = 5
# 忽略的 IP(你自己的 IP)
ignoreip = 127.0.0.1/8 ::1
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log # CentOS 用 /var/log/secure
maxretry = 5
- 启动服务:
bash
sudo systemctl start fail2ban
sudo systemctl enable fail2ban
常用命令
bash
# 查看 Fail2ban 整体状态
sudo fail2ban-client status
# 查看 SSH 监狱详细状态(包含被封禁的 IP 列表)
sudo fail2ban-client status sshd
# 查看所有被封禁的 IP(所有服务)
sudo fail2ban-client banned
# 手动封禁 IP
sudo fail2ban-client set sshd banip 192.168.1.100
# 手动解封 IP
sudo fail2ban-client set sshd unbanip 192.168.1.100
# 重新加载配置(不中断已有封禁)
sudo fail2ban-client reload
# 重启 Fail2ban 服务
sudo systemctl restart fail2ban
# 查看实时日志
sudo tail -f /var/log/fail2ban.log
# 查看 iptables 中 Fail2ban 生成的规则
sudo iptables -L -n | grep f2b
# 测试配置文件语法
sudo fail2ban-client -t
保护 Nginx/Apache
为 Nginx 添加保护:
ini
[nginx-http-auth]
enabled = true
filter = nginx-http-auth
port = http,https
logpath = /var/log/nginx/error.log
maxretry = 5
bantime = 3600
[nginx-noscript]
enabled = true
port = http,https
filter = nginx-noscript
logpath = /var/log/nginx/access.log
maxretry = 6
[nginx-badbots]
enabled = true
port = http,https
filter = nginx-badbots
logpath = /var/log/nginx/access.log
maxretry = 2
[nginx-noproxy]
enabled = true
port = http,https
filter = nginx-noproxy
logpath = /var/log/nginx/access.log
maxretry = 2
# 防止 CC 攻击(限制访问频率)
[nginx-limit-req]
enabled = true
filter = nginx-limit-req
port = http,https
logpath = /var/log/nginx/error.log
maxretry = 10
findtime = 60
bantime = 600
为 Apache 添加保护:
ini
[apache-auth]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache2/error.log
maxretry = 5
[apache-badbots]
enabled = true
port = http,https
filter = apache-badbots
logpath = /var/log/apache2/access.log
maxretry = 2
[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/apache2/error.log
[apache-overflows]
enabled = true
port = http,https
filter = apache-overflows
logpath = /var/log/apache2/error.log
maxretry = 2
[apache-shellshock]
enabled = true
port = http,https
filter = apache-shellshock
logpath = /var/log/apache2/error.log
maxretry = 1
自定义 WordPress 防护:
创建过滤器 /etc/fail2ban/filter.d/wordpress-auth.conf:
ini
[Definition]
failregex = ^<HOST> .* "POST /wp-login.php
^<HOST> .* "POST /xmlrpc.php
ignoreregex =
在 jail.local 中启用:
ini
[wordpress-auth]
enabled = true
filter = wordpress-auth
logpath = /var/log/nginx/access.log
port = http,https
maxretry = 3
findtime = 600
bantime = 7200
配置邮件通知:
ini
[DEFAULT]
# 邮件相关配置
destemail = admin@example.com
sender = fail2ban@example.com
sendername = Fail2Ban
mta = sendmail
# 选择动作(带邮件通知)
action = %(action_mwl)s
# action_ = 只封禁
# action_mw = 封禁 + 发送邮件
# action_mwl = 封禁 + 发送邮件 + 包含日志
二、CrowdSec - 新一代智能防护
什么是 CrowdSec?
CrowdSec 是 Fail2ban 的现代化替代品,具有社区威胁情报共享功能,可以实时获取全球攻击者 IP 黑名单。
安装 CrowdSec
bash
curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | sudo bash
sudo apt install crowdsec
安装防火墙插件
bash
# 安装 iptables/firewalld 插件
sudo apt install crowdsec-firewall-bouncer-iptables
安装检测场景
bash
# SSH 保护
sudo cscli collections install crowdsecurity/sshd
# Nginx 保护
sudo cscli collections install crowdsecurity/nginx
# 查看已安装场景
sudo cscli collections list
常用命令
bash
# 查看告警
sudo cscli alerts list
# 查看被封禁的 IP
sudo cscli decisions list
# 手动封禁 IP
sudo cscli decisions add --ip 192.168.1.100 --duration 4h
# 解封 IP
sudo cscli decisions delete --ip 192.168.1.100
# 查看指标
sudo cscli metrics
启用社区黑名单(推荐)
bash
# 注册账号(可选但推荐)
sudo cscli console enroll YOUR_ENROLLMENT_KEY
# 自动获取社区 IP 黑名单
sudo systemctl restart crowdsec
三、UFW - 简单实用的防火墙
什么是 UFW?
UFW (Uncomplicated Firewall) 是 Ubuntu 默认的防火墙管理工具,非常简单易用。
基本使用
bash
# 安装(Ubuntu 通常已预装)
sudo apt install ufw
# 设置默认规则
sudo ufw default deny incoming # 拒绝所有入站
sudo ufw default allow outgoing # 允许所有出站
# 允许 SSH(重要!先设置这个再启用防火墙)
sudo ufw allow 22/tcp
# 或指定端口
sudo ufw allow 2222/tcp
# 允许 HTTP 和 HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# 允许特定 IP 访问
sudo ufw allow from 192.168.1.100
# 启用防火墙
sudo ufw enable
# 查看状态
sudo ufw status verbose
# 查看规则编号
sudo ufw status numbered
# 删除规则
sudo ufw delete 3 # 删除第 3 条规则
高级规则
bash
# 限制 SSH 连接速率(防暴力破解)
sudo ufw limit 22/tcp
# 允许特定 IP 段
sudo ufw allow from 192.168.1.0/24
# 端口范围
sudo ufw allow 6000:6007/tcp
# 拒绝特定 IP
sudo ufw deny from 1.2.3.4
四、CSF - 功能全面的防火墙套件
什么是 CSF?
ConfigServer Security & Firewall (CSF) 是一个功能强大的防火墙,自带登录失败检测功能。
安装 CSF
bash
cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sudo sh install.sh
基础配置
bash
# 编辑配置文件
sudo nano /etc/csf/csf.conf
关键设置:
ini
# 改为生产模式
TESTING = "0"
# 开放端口(逗号分隔)
TCP_IN = "22,80,443"
TCP_OUT = "22,80,443"
UDP_IN = "53"
UDP_OUT = "53,123"
# 登录失败检测
LF_SSHD = "5" # SSH 5次失败封禁
LF_TRIGGER = "5" # 总共5次失败
LF_TRIGGER_PERM = "1" # 永久封禁
# 端口扫描检测
PS_INTERVAL = "300"
PS_LIMIT = "10"
常用命令
bash
# 重启 CSF
sudo csf -r
# 查看防火墙规则
sudo csf -l
# 允许 IP
sudo csf -a 192.168.1.100
# 临时允许
sudo csf -ta 192.168.1.100
# 拒绝 IP
sudo csf -d 1.2.3.4
# 移除封禁
sudo csf -dr 1.2.3.4
# 查看封禁列表
sudo csf -g 1.2.3.4
五、Logwatch - 日志监控助手
安装配置
bash
# 安装
sudo apt install logwatch
# 立即生成报告
sudo logwatch --detail High --mailto your@email.com --service all --range today
# 配置每日自动发送
sudo nano /etc/cron.daily/00logwatch
添加内容:
bash
#!/bin/bash
/usr/sbin/logwatch --output mail --mailto your@email.com --detail high
六、端口敲门 (Port Knocking)
什么是端口敲门?
通过按特定顺序访问指定端口来"解锁" SSH,增加隐蔽性。
安装 knockd
bash
sudo apt install knockd
配置
bash
sudo nano /etc/knockd.conf
ini
[openSSH]
sequence = 7000,8000,9000
seq_timeout = 5
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
[closeSSH]
sequence = 9000,8000,7000
seq_timeout = 5
command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
启用服务
bash
sudo nano /etc/default/knockd
# 设置 START_KNOCKD=1
sudo systemctl enable knockd
sudo systemctl start knockd
使用方法
bash
# 客户端安装 knock
sudo apt install knockd
# 敲门序列(打开 SSH)
knock your-server.com 7000 8000 9000
# 连接 SSH
ssh user@your-server.com
# 关闭 SSH
knock your-server.com 9000 8000 7000
七、实战:一键加固脚本
基础加固脚本
bash
#!/bin/bash
echo "=== Linux 服务器安全加固脚本 ==="
# 更新系统
echo "[1/7] 更新系统..."
sudo apt update && sudo apt upgrade -y
# 安装必要工具
echo "[2/7] 安装安全工具..."
sudo apt install -y ufw fail2ban unattended-upgrades logwatch
# 配置 UFW
echo "[3/7] 配置防火墙..."
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw limit 22/tcp
sudo ufw --force enable
# 配置 Fail2ban
echo "[4/7] 配置 Fail2ban..."
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
# 启用自动安全更新
echo "[5/7] 启用自动安全更新..."
sudo dpkg-reconfigure -plow unattended-upgrades
# 禁用 root 远程登录
echo "[6/7] 加固 SSH 配置..."
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
sudo sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo systemctl restart sshd
# 完成
echo "[7/7] 加固完成!"
echo ""
echo "建议后续操作:"
echo "1. 创建普通用户并添加 sudo 权限"
echo "2. 配置 SSH 密钥登录"
echo "3. 禁用密码登录(PasswordAuthentication no)"
echo "4. 修改 SSH 默认端口"
保存为 security_hardening.sh,然后执行:
bash
chmod +x security_hardening.sh
sudo ./security_hardening.sh
八、安全最佳实践
1. SSH 加固
bash
sudo nano /etc/ssh/sshd_config
推荐配置:
Port 2222 # 修改默认端口
PermitRootLogin no # 禁止 root 登录
PasswordAuthentication no # 禁用密码(仅用密钥)
PubkeyAuthentication yes # 启用公钥认证
MaxAuthTries 3 # 最多尝试 3 次
LoginGraceTime 30 # 登录超时 30 秒
AllowUsers username # 只允许特定用户
2. 定期检查
bash
# 查看最近登录
last -20
# 查看当前登录用户
w
# 查看失败登录
sudo lastb
# 检查可疑进程
ps aux | grep -E 'xmrig|miner|cryptonight'
# 检查网络连接
sudo netstat -tulpn | grep ESTABLISHED
3. 监控系统资源
bash
# CPU 使用率
top -bn1 | head -20
# 内存使用
free -h
# 磁盘使用
df -h
# 检查异常进程
ps aux --sort=-%cpu | head -10
九、工具对比与选择
| 工具 | 难度 | 功能 | 推荐场景 | 资源占用 |
|---|---|---|---|---|
| UFW | ⭐ | 基础防火墙 | 个人服务器,初学者 | 极低 |
| Fail2ban | ⭐⭐ | 登录保护,反应式 | 所有场景,必装 | 低 |
| CrowdSec | ⭐⭐ | 智能防护,主动式 | 进阶用户,想要社区情报 | 中等 |
| CSF | ⭐⭐⭐ | 全面防护 | 需要 Web 界面管理 | 中等 |
| Port Knocking | ⭐⭐⭐ | 隐藏端口 | 高度安全需求 | 极低 |
Fail2ban vs CrowdSec 深度对比
工作原理:
- Fail2ban(反应式): 等攻击者尝试登录后,检测到异常才封禁。就像事后抓小偷。
- CrowdSec(主动式): 使用全球威胁情报数据库,攻击者还没碰到你的服务器就已经被封禁了。就像提前看到黑名单。
核心差异:
| 对比项 | Fail2ban | CrowdSec |
|---|---|---|
| 诞生年份 | 2004 年(老牌) | 2020 年(新秀) |
| 防护方式 | 本地日志分析 | 本地分析 + 社区威胁情报 |
| 检测能力 | 正则表达式匹配 | 行为分析 + 模式识别 |
| 资源占用 | ~5-10MB 内存 | ~30-50MB 内存 |
| 配置难度 | 简单,但高级配置复杂 | 中等,文档完善 |
| 多服务器 | 每台独立配置 | 支持集中管理 |
| 误封率 | 较低 | 更低(社区验证) |
| 社区支持 | 成熟稳定 | 活跃创新 |
优势对比:
Fail2ban 优势:
- ✅ 极低资源占用(适合小内存 VPS)
- ✅ 立即封禁(检测到就立刻 ban)
- ✅ 成熟稳定(18年历史)
- ✅ 配置简单(基础使用)
- ✅ 不依赖第三方服务
CrowdSec 优势:
- ✅ 主动防御(攻击前就阻止)
- ✅ 全球威胁情报(每天处理 100 万+ IP)
- ✅ 行为分析(识别复杂攻击模式)
- ✅ 多服务器联动(一台被攻击,所有服务器同步封禁)
- ✅ 零日漏洞防护(社区快速响应新威胁)
- ✅ 可视化仪表板(Web 界面查看攻击)
实际使用建议:
- 小型 VPS(1GB 内存以下): Fail2ban
- 生产环境(多台服务器): CrowdSec
- 高流量网站: CrowdSec
- 学习练手: Fail2ban(简单直接)
- 企业安全: CrowdSec(更智能全面)
可以同时使用吗?
不建议!它们会互相冲突。选一个就够了:
- 如果你只有一台小服务器 → Fail2ban
- 如果你想要更强大的防护 → CrowdSec
UFW vs iptables 关系解释
很多人困惑:UFW 和 iptables 有什么关系?
简单理解:
- Netfilter: Linux 内核的防火墙功能(底层引擎)
- iptables: 直接操作 Netfilter 的命令行工具(底层工具)
- UFW: iptables 的简化版界面(高层工具)
- firewalld: iptables 的另一个前端(RedHat/CentOS)
比喻说明:
- Netfilter = 汽车引擎
- iptables = 直接操作引擎(需要懂机械)
- UFW = 自动挡汽车(简单易用)
- firewalld = 另一种自动挡(CentOS 专用)
命令对比:
bash
# iptables 方式(复杂)
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 22 -j ACCEPT
# UFW 方式(简单)
sudo ufw allow 80/tcp
sudo ufw allow from 192.168.1.0/24 to any port 22
关系总结:
- UFW 不是 iptables 的替代品
- UFW 是 iptables 的简化前端
- UFW 的命令最终会转换成 iptables 规则
- 可以用
sudo iptables -L -n查看 UFW 生成的实际规则
重要提醒:
- ⚠️ 不要同时使用 UFW 和 firewalld(会冲突)
- ⚠️ 如果用 UFW,不要手动修改 iptables 规则(会被覆盖)
- ⚠️ Ubuntu 用 UFW,CentOS 用 firewalld
推荐组合
入门套餐(个人博客/小项目):
UFW + Fail2ban
标准套餐(生产环境):
UFW + CrowdSec + Logwatch
企业套餐(高安全需求):
CSF + CrowdSec + Port Knocking + OSSEC
十、应急响应
发现服务器被入侵怎么办?
- 立即断开可疑连接:
bash
# 查看当前连接
sudo netstat -antp | grep ESTABLISHED
# 断开特定连接
sudo kill -9 PID
- 停止恶意进程:
bash
# 查找挖矿程序
ps aux | grep -E 'xmrig|miner'
# 终止进程
sudo pkill -9 xmrig
- 删除恶意文件:
bash
# 查找可疑目录
find /tmp /var/tmp /dev/shm -type f -name ".*"
# 删除
sudo rm -rf /path/to/malware
- 检查启动项:
bash
# 检查 crontab
crontab -l
sudo crontab -l
# 检查 systemd
sudo systemctl list-units --type=service --state=running
- 修改所有密码:
bash
# 修改用户密码
sudo passwd username
# 生成新的 SSH 密钥
ssh-keygen -t ed25519
- 重新加固系统(参考上面的脚本)
十一、常见问题 FAQ
Q1: Fail2ban 封禁了我自己的 IP 怎么办?
方法一:通过其他 IP 连接
bash
# 解封自己
sudo fail2ban-client set sshd unbanip YOUR_IP
方法二:通过服务器控制台
bash
# 临时停止 Fail2ban
sudo systemctl stop fail2ban
# 清除所有封禁
sudo fail2ban-client unban --all
# 添加自己的 IP 到白名单
sudo nano /etc/fail2ban/jail.local
# 在 [DEFAULT] 下添加:
ignoreip = 127.0.0.1/8 YOUR_IP
# 重启服务
sudo systemctl start fail2ban
Q2: 如何查看哪些 IP 被封禁了?
bash
# 查看 SSH 监狱的封禁列表
sudo fail2ban-client status sshd
# 查看所有监狱的封禁
sudo fail2ban-client banned
# 查看 iptables 规则
sudo iptables -L f2b-sshd -n --line-numbers
Q3: 封禁时间可以设置为永久吗?
bash
# 在 jail.local 中设置
[sshd]
bantime = -1 # 永久封禁
# 或者设置很长时间
bantime = 31536000 # 一年(秒)
Q4: Fail2ban 和 UFW 可以同时使用吗?
可以!它们不冲突,而是互补:
- UFW: 管理基础防火墙规则(允许哪些端口)
- Fail2ban: 动态封禁恶意 IP
bash
# 正确的配置顺序
sudo ufw allow 22/tcp
sudo ufw enable
# 然后安装 Fail2ban
sudo apt install fail2ban
Q5: 修改 SSH 端口后 Fail2ban 不工作?
需要更新配置中的端口号:
ini
[sshd]
enabled = true
port = 2222 # 改成你的 SSH 端口
filter = sshd
logpath = /var/log/auth.log
Q6: 如何测试 Fail2ban 是否工作?
bash
# 从另一台机器故意输错密码
ssh wronguser@your-server
# 在服务器上查看日志
sudo tail -f /var/log/fail2ban.log
# 检查是否被封禁
sudo fail2ban-client status sshd
Q7: CrowdSec 和 Fail2ban 可以同时用吗?
不推荐! 它们功能重复,会互相干扰:
- 都会修改 iptables 规则
- 可能重复封禁同一个 IP
- 浪费系统资源
选择建议:
- 小服务器 → Fail2ban
- 多服务器/高流量 → CrowdSec
Q8: 为什么有些 IP 一直尝试登录但没被封禁?
可能原因:
- 每次尝试间隔太长(超过 findtime)
ini
# 延长查找时间窗口
findtime = 3600 # 改为 1 小时
- 尝试次数未达到阈值
ini
# 降低阈值
maxretry = 3 # 改为 3 次
- IP 在白名单中
bash
# 检查白名单
grep ignoreip /etc/fail2ban/jail.local
Q9: 如何防止 CC 攻击?
方法一:使用 Fail2ban 限速过滤器
ini
[nginx-limit-req]
enabled = true
filter = nginx-limit-req
port = http,https
logpath = /var/log/nginx/error.log
maxretry = 10
findtime = 60
bantime = 600
方法二:在 Nginx 中配置限速
nginx
http {
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
server {
location / {
limit_req zone=one burst=20;
}
}
}
方法三:使用 CrowdSec
bash
# 安装 HTTP 场景
sudo cscli collections install crowdsecurity/nginx
sudo systemctl reload crowdsec
Q10: 服务器重启后 Fail2ban 封禁还有效吗?
默认情况:重启后封禁会失效
如果要持久化封禁:
ini
# 在 jail.local 中添加
[DEFAULT]
# 使用数据库存储封禁
dbfile = /var/lib/fail2ban/fail2ban.sqlite3
dbpurgeage = 86400 # 保留时间(秒)
或使用 ipset:
bash
# 安装 ipset
sudo apt install ipset
# 修改 jail.local
[DEFAULT]
banaction = iptables-ipset-proto6
十二、排错指南
Fail2ban 服务无法启动
bash
# 1. 检查配置文件语法
sudo fail2ban-client -t
# 2. 查看详细错误日志
sudo journalctl -xe -u fail2ban
# 3. 测试配置文件
sudo fail2ban-client -x start
# 4. 常见错误修复
# 错误:找不到日志文件
# 解决:确认日志路径正确
ls -la /var/log/auth.log # Ubuntu
ls -la /var/log/secure # CentOS
误封禁了 Cloudflare IP
bash
# 添加 Cloudflare IP 到白名单
sudo nano /etc/fail2ban/jail.local
[DEFAULT]
ignoreip = 127.0.0.1/8
173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
141.101.64.0/18
108.162.192.0/18
190.93.240.0/20
UFW 和 Fail2ban 规则冲突
bash
# 确保 UFW 先允许端口
sudo ufw allow 22/tcp
sudo ufw reload
# 然后启动 Fail2ban
sudo systemctl restart fail2ban
# 检查规则顺序
sudo iptables -L -n --line-numbers
总结
服务器安全是一个持续的过程,不是一次性设置就万事大吉。建议:
- 必装工具:UFW + Fail2ban(或 CrowdSec)
- 定期检查:每周查看日志和系统状态
- 及时更新:启用自动安全更新
- 密钥登录:禁用密码,只用 SSH 密钥
- 备份数据:定期备份重要数据
- 监控告警:配置邮件或消息通知
- 最小权限:只开放必要的端口和服务
记住:安全无小事,预防胜于治疗!
快速参考卡片
Fail2ban 速查
bash
# 状态查看
sudo fail2ban-client status
sudo fail2ban-client status sshd
sudo fail2ban-client banned
# 封禁操作
sudo fail2ban-client set sshd banip IP地址
sudo fail2ban-client set sshd unbanip IP地址
# 服务控制
sudo systemctl restart fail2ban
sudo systemctl status fail2ban
sudo fail2ban-client reload
# 日志查看
sudo tail -f /var/log/fail2ban.log
UFW 速查
bash
# 基础操作
sudo ufw enable
sudo ufw disable
sudo ufw status verbose
sudo ufw status numbered
# 规则管理
sudo ufw allow 端口/协议
sudo ufw deny 端口/协议
sudo ufw delete 规则编号
sudo ufw reset
# 常用规则
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw limit 22/tcp # 限速 SSH
CrowdSec 速查
bash
# 状态查看
sudo cscli metrics
sudo cscli alerts list
sudo cscli decisions list
# 场景管理
sudo cscli collections list
sudo cscli collections install 名称
# 封禁操作
sudo cscli decisions add --ip IP地址 --duration 4h
sudo cscli decisions delete --ip IP地址
参考资源
官方文档
- Fail2ban: https://www.fail2ban.org/wiki/index.php/Main_Page
- CrowdSec: https://docs.crowdsec.net
- UFW: https://help.ubuntu.com/community/UFW
- iptables: https://www.netfilter.org/documentation/
社区资源
- Fail2ban Wiki: https://github.com/fail2ban/fail2ban/wiki
- CrowdSec Hub: https://hub.crowdsec.net
- Linux 安全: https://www.cyberciti.biz/tips/linux-security.html
工具下载
- Fail2ban GitHub: https://github.com/fail2ban/fail2ban
- CrowdSec GitHub: https://github.com/crowdsecurity/crowdsec
- CSF: https://configserver.com/cp/csf.html
推荐阅读
- 《Linux 服务器安全最佳实践》
- 《iptables 防火墙完全指南》
- 《入侵检测与防御系统》
文档版本 : v1.0
最后更新 : 2025年12月6日
许可: CC BY-SA 4.0