全球主机交流论坛
标题:
求一段简单的脚本代码
[打印本页]
作者:
查无此人
时间:
2016-4-13 15:29
提示:
作者被禁止或删除 内容自动屏蔽
作者:
今晚我是你的
时间:
2016-4-13 16:03
只会bat
作者:
cgs3238
时间:
2016-4-13 16:09
tail -n 1 nginx/log/access.log | grep MSIE | awk '{print $1}' | xargs -i iptables -I INPUT -s {}/32 -j DROP
作者:
leoynx
时间:
2016-4-13 16:14
本帖最后由 leoynx 于 2016-4-13 16:16 编辑
#!/bin/bash
logfile=
while true
do
tail -1 a | grep -sq MISE
if [[ "$?" -eq 0 ]];then
ip=$(tail -1 "$logfile" | grep -oE "([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}")
echo $ip
fi
sleep 5
done
复制代码
logfile=这里添上日志的绝对路径,echo $ip这行换成你要添加的iptables命令,$ip就是最后一行的获取到的ip.可以把这脚本放到rc.local,或者去掉sleep 5,放到crontab 里面就去掉while true这个循环
作者:
查无此人
时间:
2016-4-13 16:17
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 全球主机交流论坛 (https://sunk.eu.org/)
Powered by Discuz! X3.4