美文网首页IT技术分享
网站遭遇CC及DDOS攻击紧急处理方案

网站遭遇CC及DDOS攻击紧急处理方案

作者: 封闭_e657 | 来源:发表于2019-08-23 15:50 被阅读0次

检测访问是否是CC攻击的命令:

80口为网站的访问端口,可以根据实际情况进行修改

# netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20 | netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A[i],i}' |sort -rn|head -n20

如改成8888

netstat -anlp|grep 8888|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20 | netstat -ant |awk '/:8888/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A[i],i}' |sort -rn|head -n20

找出访问比较多的IP,IP地址为荷兰(明显不是企业所在地,直接封堵)

6 139.162.153.143

3 139.162.218.121

对可疑IP进行封堵

封网段

iptables -I INPUT -s 139.162.153.143/16 -j DROP

iptables -I INPUT -s 139.162.218.121/16 -j DROP

iptables -I INPUT -s 205.177.226.156/16 -j DROP

保存规则,保证下次启动规则适用

service iptables save

检测是否是syn flooding DDOS攻击

检测syn_recv命令

检查连接数增多,并且SYN_RECV 连接特别多:

# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

TIME_WAIT 16855

CLOSE_WAIT 21

SYN_SENT 99

FIN_WAIT1 229

FIN_WAIT2 113

ESTABLISHED 8358

SYN_RECV 48965

CLOSING 3

LAST_ACK 313

根据经验,正常时检查连接数如下:

# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

TIME_WAIT 612

CLOSE_WAIT 2

FIN_WAIT1 3

FIN_WAIT2 535

ESTABLISHED 257

SYN_RECV 4

根据netstat查看到的对方IP特征并进行封堵:

# netstat -na |grep SYN_RECV|more

对可疑IP进行封堵封堵

常用命令

封单个IP的命令是:

iptables -I INPUT -s 211.1.0.0 -j DROP

封IP段的命令是:

iptables -I INPUT -s 211.1.0.0/16 -j DROP

iptables -I INPUT -s 211.2.0.0/16 -j DROP

iptables -I INPUT -s 211.3.0.0/16 -j DROP

封整个B段的命令是:

iptables -I INPUT -s 211.0.0.0/8 -j DROP

封几个段的命令是:

iptables -I INPUT -s 61.37.80.0/24 -j DROP

iptables -I INPUT -s 61.37.81.0/24 -j DROP

参考:http://drops.wooyun.org/tips/2457

转载于:https://www.cnblogs.com/reblue520/p/6239849.html

    有服务器需求请加QQ1911624872咨询

相关文章

网友评论

    本文标题:网站遭遇CC及DDOS攻击紧急处理方案

    本文链接:https://www.haomeiwen.com/subject/vadtectx.html