1)统计80端口连接数:
netstat -nat|grep -i "80"|wc -l
2)统计httpd协议连接数:
ps -ef|grep httpd|wc -l
3)统计已连接上的,状态为"established":
netstat -na|grep ESTABLISHED|wc -l
4) 查看连接数最多的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],i}' |sort -rn|head -n20
5)开始封禁IP,具体可以看我下面运行的命令.本文主要是采用iptables进行封禁:
iptables -I INPUT -s 174.127.94.0/16 -j DROP
6)查看连接数最多的ip:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n