网站首页  软件下载  游戏下载  翻译软件  电子书下载  电影下载  电视剧下载  教程攻略

请输入您要查询的教程攻略:

 

标题 Linux如何利用shell脚本抵御小量的ddos攻击
分类 软件教程
内容     
    Linux系统shell脚本的作用强大,用于执行各种命令,网站被小量ddos攻击可通过shell脚本进行抵御,下面小编就给大家讲解下Linux shell脚本分析Nginx日志如何抵抗ddos攻击。
    Linux如何利用shell脚本抵御小量的ddos攻击
    实现方式:
    1. 攻击特征,不同ip不断POST网站首页,造成资源消耗过度
    2. 分析nginx访问日志,判断POST特征取得客户端访问ip
    3. 将连接数大于50的攻击ip封杀
    4. 记录攻击ip到文档
    5. 每次取得的攻击ip与已有攻击ip比较
    查看源代码:
    #!/bin/bash
    WEBSITES=(
    example.com
    )
    minute_now=`date +%M`
    max_connections=50
    banips=“/wwwdata/jobs/banips.txt”
    for site in ${WEBSITES[*]}
    do
    access_log_file=“/wwwdata/logs/${site}.access.log”
    if [ -f “${access_log_file}” ]
    then
    cat ${access_log_file} | grep POST | awk ‘{print $1}’ | sort |uniq -c| sort -nr 》 /wwwdata/jobs/ip_records.txt
    lines=`wc -l /wwwdata/jobs/ip_records.txt | awk ‘{print $1}’`
    echo “Lines: $lines”
    i=1
    while [ ${i} -le ${lines} ]
    do
    ip_record=`head -${i} /wwwdata/jobs/ip_rec41. 说分手的时候不好吵闹。毕竟两个在在一齐那么久,分了他也会难过,只是他比较明智,不想束缚你的或他的明天。好聚好散,以后,还是朋友。ords.txt | tail -1 | sed ‘s/^[ \t]*//g’`
    ip_count=`echo ${ip_record} | awk ‘{print $1}’`
    ip_address=`echo ${ip_record} | awk ‘{print $2}’`
    echo “${ip_count} ${ip_address}”
    if [ ${ip_count} -gt ${max_connections} ]
    then
    banned=`cat ${banips} | grep ${ip_address} | wc -l`
    if [ ${banned} -lt 1 ]
    then
    iptables -A INPUT -s x.x.x.x -p tcp -m state --state NEW -m tcp --dport 80 -j DROP
    echo ${ip_address} 》》 ${banips}
    fi
    fi
    i=`expr ${i} + 1`
    done
    service iptables save
    service iptables restart
    if [ ${minute_now} -eq 30 ]
    then
    cat ${access_log_file} 》》 /wwwdata/logs/olds/${site}.access.log
    cat /dev/null 》 ${access_log_file}
    fi
    fi
    done
    if [ ${minute_now} -eq 30 ]
    then
    service nginx restart
    fi
    Linux系统shell脚本通过分析Nginx日志,能够对微量的ddos攻击起到防御作用,你也可使用iptables进行防止。
        Linux如何利用shell脚本抵御小量的ddos攻击神情专注功丰富多彩败垂成41. 把孔子所不屑的“三思而行”的踌躇让给老年人吧!年轻不就是有莽撞往前去的勇气吗?年轻就是手里握着大把岁月的筹码那么,在命运的赌局里作乾坤一掷的时候,虽不一定赢,气势上总该能壮阔吧?make suggestions on 对……提出建议255.月落乌啼霜满天,江枫渔火对愁眠。姑苏城外寒山寺,夜半钟声到客船。张继《枫桥夜泊》    哀筝一弄湘江曲,声声写尽湘波绿。纤指十三弦,细将幽恨传。当筵秋水慢,玉柱斜飞雁。弹到断肠时,春山眉黛低。落落盘踞虽得地,冥冥孤高多烈风。linuxshell脚本,nginx防ddos,nginxddos攻击It has taken a long time to convince the public that free enterprise does not mean that a company should be free to pollute the air, foul the rivers, and destroy the forests.
随便看

 

霍普软件下载网教程攻略栏目提供软件使用教程、手机游戏攻略等方法技巧。

 

Copyright © 2002-2024 101bt.net All Rights Reserved
更新时间:2025/3/12 10:02:15