Count apache404 errors ip and join iptables Firewall
#! / bin/bash
# apache log error missing 404
# get the current log time
Date= `date +% Y% m% d`
# output log files to LOG variables
LOG='pay_access_'$date'.log'
# 404 error filtering
Awk'$9 = = 404 {print $1}'$LOG >. / tmplog
Awk'{a [$0] + +} END {for (i in a) print iCommand a [I]} 'tmplog | sort >. / tmpl
Awk'$2 > 10 {print $1} 'tmpl >. / tmpip
/ etc/init.d/iptables restart
# read the ip; in the file line by line and add it to the iptables firewall
Ip= "tmpip"
While read LINE
Do
Iptables-An INPUT-s $LINE-p tcp-- dport 80-j DROP
Done < $ip
Add disable ip as temporary, so every time you restart the iptables policy, it will clear.
Then add scheduled tasks.