標籤:ant script log cti tab 檔案 table lte pat
--安裝fail2ban
yum install -y epel-release
yum install -y fail2ban
--配置fail2ban
vi /etc/fail2ban/jail.conf
[http-get-dos]
enabled = true
port = http
filter = http-get-dos
logpath = /home/wwwlogs/access.log
maxretry = 100
findtime = 5
bantime = 600
action = iptables[name=HTTP,port=http,protocol=tcp]
/* 參數含義
filter = http-get-dos #--filter.d/http-get-dos.conf 檔案名稱
logpath = /home/wwwlogs/access.log #--需要監控nginx日誌log
maxretry = 100 #-- 最多訪問100
findtime = 10 #-- 10秒
bantime = 1200 #-- 20分鐘
*/
vi /etc/fail2ban/filter.d/http-get-dos.conf
[Definition]
failregex = <HOST> -.*- .*HTTP/1.* .* .*$
ignoreregex =
--配置fail2ban日誌
vi /etc/fail2ban/fail2ban.conf
loglevel = WARNING
logtarget = /var/log/fail2ban.log
--重啟生效
service fail2ban restart
--屏蔽日誌
tail -f /var/log/fail2ban.log
--#刪除屏蔽
iptables -D f2b-HTTP 1
--定時清理 nginx / fail2ban 日誌
vi /root/scripts/del_cc_log.sh
#! /bin/bash
cat /dev/null > /home/wwwlogs/access.log
cat /dev/null > /var/log/fail2ban.log
crontab -e
30 3 * * 0 sh /root/scripts/del_cc_log.sh
--開啟crontab
/etc/init.d/crond start
chkconfig --list|grep crond
--屏蔽ssh探測
vi /etc/fail2ban/jail.conf
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
logpath = /var/log/secure
maxretry = 10
bantime = 144000
--#刪除屏蔽
iptables -D f2b-SSH 1
nginx下使用fail2ban防止網站被CC