Iptablesddos/cc automatic shielding script

Source: Internet
Author: User
Recently, CC (a type of DDOS) frequently interferes with each other and shares an iptables anti-DDOS script. Run crond once every minute. ############## KILLDDOS ############### iptables_log/data/logs/iptables_conf.log ### iptables: configure the export path, can be arbitrarily modified # CC (DDOS) is frequently disturbed and shared IptablesScripts that shield DDOS attacks.
Run crond once every minute.

############## Kill ddos ##############
Iptables_log = "/data/logs/iptables_conf.log"
### Iptables configuration export path, which can be modified as needed ###
########################################
Status = 'netstat-na | awk' $5 ~ /[0-9] +: [0-9] +/{print $5} '| awk-F ": "-- '{print $1}' | sort-n | uniq-c | sort-n | grep-v 127.0.0.1 | tail-n 1'
NUM = 'echo $ status | awk' {print $1 }''
IP = 'echo $ status | awk' {print $2 }''
Result = 'echo "$ NUM> 200" | bc'
### If the number of concurrent connections exceeds 200, kill it! ###
If [[$ result = 1]
Then
Echo IP: $ IP is over $ NUM, ban it!
/Sbin/iptables-a input-s $ IP-j DROP
Fi
########################################
Iptables-save >$ {iptables_log}
### Output the current iptable configuration as a log ###
########################################

Some friends pointed out that "??? Ben ???? Pour the values of tail-n 1 and grep-v127.0.0.1, no? T some affection? R ?? Jain? What kind of insurance does Huang Weimei copy ?? Remote planting? What is the copy of malaria? Br/>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.