#!/bin/bash #fix by Leipore at 2014-12-18ddos-autoprotection.sh Touch/root/back_bad_ip.txt Time= ' date + '%y-%m-%d%h:%m:%s ' Ar= ' wc-l/root/back_bad_ip.txt |awk ' {print $} ' Sleep 1 Netstat-an |grep |grep-v "STREAM" |awk ' {print $} ' |sort | Awk-f: ' {print $} ' |uniq-c |awk ' $ > $ {print $1,$2} ' >/root/bad_ip; Cat/root/bad_ip |awk-vtime= "$time" ' {Print time ' | "$" | ">>/root/back_bad_ip.txt}" Ar2= ' wc-l/root/back_bad_ip.txt |awk ' {print $} ' For i in ' awk ' {print $ {} '/root/bad_ip ';d o If [' $i ' = ' ""];then Exit:q Else Iptables-i input-s $i-j DROP Fi Done sum=$[$ar 2-$ar] If ["$sum"-eq 0];then Exit Else /usr/lib/sendmail-f [Email protected] [email protected] -S Smtp.xx.cn-u "Subject:report"-xu [email protected]-XP xxxxxx-m </root/back_bad_ip.txt Fi |
#!/bin/bash While [1] Do sh/scripts/ddos-autoprotection.sh Sleep 30 Done |
Nohup sh/scripts/ddos-check.sh & (boot start)
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
Disadvantages:
Repeat iptables Disabled.
Do not write iptables daily, that is to say, restart failure
Need to restart iptables (optional)
The link between the agent and the agent below this limit will also be limited such as the LO Nic local network card, etc.
Automatically intercept DDoS attacks with shell scripts