功能说明: Netstat用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。
常用参数 :
-a或–all 显示所有连线中的Socket。
-n或–numeric 直接使用IP地址,而不通过域名服务器。
netstat 常用方式
netstat -nat|grep 80|wc -l
#统计80端口连接数
netstat -nat|awk '{print awk $NF}'|sort|uniq -c|sort -n
#统计各种链接状态的数量
netstat -nat|grep serverip:80|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n
netstat -nat|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n
#查看有没有异常的连接IP,如果有可能被DOC了
> netstat -an
Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 ::ffff:61.145.118.216:60869 ::ffff:61.145.118.203:3306 TIME_WAIT tcp 1 0 ::ffff:61.145.118.216:10769 ::ffff:61.145.118.203:3306 CLOSE_WAIT tcp 1 0 ::ffff:61.145.118.216:13850 ::ffff:61.145.118.203:3306 CLOSE_WAIT tcp 1 0 ::ffff:61.145.118.216:46312 ::ffff:61.145.118.203:3306 CLOSE_WAIT tcp 1 0 ::ffff:61.145.118.216:26972 ::ffff:61.145.118.203:3306 CLOSE_WAIT tcp 0 0 ::ffff:61.145.118.216:13123 ::ffff:61.145.118.203:3306 ESTABLISHED |
Recv-Q
The count of bytes not copied by the user program connected to this socket.
Send-Q
The count of bytes not acknowledged by the remote host.