Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Count apache404 errors ip and join iptables Firewall

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

#! / 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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report