分析apache日志,统计ip访问频次命令

时间:2024-05-23 21:35:32

统计访问频次最高的10个ip:

cat /var/log/httpd/access_log |awk '{print $1}'|sort|uniq -c|sort -nr|head -10

统计恶意ip(结果为403的请求)

cat /var/log/httpd/access_log|awk '{if($9=='403'){print $1}}'|sort|uniq|sort -nr

请求样本如下:

61.160.207.44 - - [17/Mar/2015:06:30:55 +0000] "CONNECT reg.163.com:443 HTTP/1.0" 403 1374 "-" "Mozilla/5.0"