Linux查看系统是否被cc攻击的方法

cc攻击主要攻击页面,模拟很多用户来不断的访问网站,导致系统资源被大量占用,那么在Linux系统中,我们要如何知道自己是否被cc攻击了呢?

Linux查看系统是否被cc攻击的方法


查看所有80端口的连接数
netstat -nat|grep -i “80”|wc -l
对连接的IP按连接数量进行排序
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
查看TCP连接状态
netstat -nat |awk ‘{print $6}’|sort|uniq -c|sort -rn
netstat -n | awk ‘/^tcp/ {++S[$NF]};END {for(a in S) print a,S[a]}’
netstat -n | awk ‘/^tcp/ {++state[$NF]}; END {for(key in state) print key,“\t”,state[key]}’
netstat -n | awk ‘/^tcp/ {++arr[$NF]};END {for(k in arr) print k,“\t”,arr[k]}’
netstat -n |awk ‘/^tcp/ {print $NF}’|sort|uniq -c|sort -rn
netstat -ant | awk ‘{print $NF}’ | grep -v ‘[a-z]’ | sort | uniq -c
查看80端口连接数最多的20个IP
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}’ |sort -rn|head -n20
用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F“ 。” ‘{print $1“ 。”$2“ 。”$3“ 。”$4}’ | sort | uniq -c | sort -nr |head -20
查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk ‘{print $5}’|sort|uniq -c|sort -rn|head -n20
查找较多的SYN连接
netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
封单个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
封整个段的命令是:
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
想在服务器启动自运行的话有三个方法:
1、把它加到/etc/rc.local中
2、iptables-save 》/etc/sysconfig/iptables可以把你当前的iptables规则放到/etc/sysconfig/iptables中,系统启动iptables时自动执
行 。
3、service iptables save 也可以把你当前的iptables规则放/etc/sysconfig/iptables中,系统启动iptables时自动执行 。
后两种更好此,一般iptables服务会在network服务之前启来,更安全 。
解封的话:
iptables -D INPUT -s IP地址 -j REJECT
iptables -F 全清掉了
【Linux查看系统是否被cc攻击的方法】 相较于Windows系统下cc攻击的查看,Linux系统的查看相对复杂些,也比较难懂,需要一定的系统知识储备 。

    推荐阅读