您好,登錄后才能下訂單哦!
#!/bin/bash
#apache日志過略404錯(cuò)誤
#獲取當(dāng)前日志時(shí)間
date=`date +%Y%m%d`
#將日志文件輸出到LOG變量
LOG='pay_access_'$date'.log'
#404錯(cuò)誤過濾
awk '$9 == 404 {print $1}' $LOG >./tmplog
awk '{a[$0]++}END{for(i in a)print i,a[i]}' tmplog | sort >./tmpl
awk '$2>10 {print $1}' tmpl >./tmpip
/etc/init.d/iptables restart
#逐行讀取文件內(nèi)ip;添加到iptables防火墻內(nèi)
ip="tmpip"
while read LINE
do
iptables -A INPUT -s $LINE -p tcp --dport 80 -j DROP
done < $ip
添加禁止ip為臨時(shí)的所以每次重啟iptables策略就會(huì)清空
之后添加計(jì)劃任務(wù)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。