1)统计80端口连接数:
1
| netstat -nat|grep -i "80"|wc -l
|
2)统计httpd协议连接数:
3)统计已连接上的,状态为”established”:
1
| netstat -na|grep ESTABLISHED|wc -l
|
- 查看连接数最多的ip:
1
| 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进行封禁:
1
| iptables -I INPUT -s 174.127.94.0/16 -j DROP
|
6)查看连接数最多的ip:
1
| netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
|