溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

統(tǒng)計(jì)apache404錯(cuò)誤ip并加入iptables防火墻

發(fā)布時(shí)間:2020-07-22 08:39:24 來源:網(wǎng)絡(luò) 閱讀:606 作者:wtiger 欄目:安全技術(shù)

#!/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ù)。

向AI問一下細(xì)節(jié)

免責(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)容。

AI