欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

linux下2个检查tcp连接的命令

程序员文章站 2022-08-26 16:29:53
1 检测web服务器的链接数量及状态: netstat -ant|awk '{print $5 "\t" $6}'|grep "::ffff:"|sed -e '...

1 检测web服务器的链接数量及状态:

netstat -ant|awk '{print $5 "\t" $6}'|grep "::ffff:"|sed -e 's/::ffff://' -e 's/:[0-9]*//' |sort|uniq -c| sort -rn|head -10

结果:
122 125.162.71.199 time_wait
99 79.119.125.43 time_wait
81 125.167.243.77 time_wait
75 110.137.106.75 time_wait
29 118.97.140.166 time_wait
29 115.192.138.175 time_wait
23 70.231.252.244 time_wait
22 114.58.168.27 time_wait
17 219.95.10.58 time_wait
15 125.160.90.214 time_wait


检测所有的tcp连接数量及状态

netstat -ant|awk '{print $5 "\t" $6}' |grep "[1-9][0-9]*\."|sed -e 's/::ffff://' -e 's/:[0-9]*//'|sort|uniq -c|sort -nr|head -10

结果:
143 79.119.125.43 time_wait
97 110.137.106.75 time_wait
54 125.162.71.199 time_wait
52 121.120.140.19 time_wait
31 114.79.21.172 time_wait
23 118.97.140.166 time_wait
19 70.231.252.244 time_wait
19 114.58.168.27 time_wait
18 219.95.10.58 time_wait
13 115.192.138.175 time_wait

有需要的朋友可以拿去收藏