设为首页 收藏本站
查看: 1249|回复: 0

[经验分享] linux-netstat输出的网络连接状态信息

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-3-23 09:21:29 | 显示全部楼层 |阅读模式
[iyunv@web-nginx-idc0E-node ~]# netstat -n|head  -3
Active Internet connections (w/o servers)
Proto    Recv-Q   Send-Q    Local Address        Foreign Address         State      
tcp        0        52     192.168.1.165:22     192.168.1.10:59337     ESTABLISHED


一共六列:
第一列为socket使用的协议。

[iyunv@web-nginx-idc0E-node1 ~]$ netstat -n |awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
TIME_WAIT 9137
CLOSE_WAIT 207
FIN_WAIT1 547
ESTABLISHED 597
FIN_WAIT2 74
SYN_RECV 70
CLOSING 55
LAST_ACK 8

[iyunv@web-nginx-idc0E-node ~]# man netstat
OUTPUT
Active Internet connections (TCP, UDP, raw)
Proto
The protocol (tcp, udp, raw) used by the socket.
第一列为socket使用的协议。

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.
第三列为已经发送的但是没有被远程主机确认收到的字节数。

Local Address
Address and port number of the local end of the socket.Unless the --numeric(-n)
optionisspecified,thesocketaddress is resolved to its canonical host name
(FQDN), and the port number is translated into the corresponding service name.
第四列为 本地的地址及端口。

Foreign Address
Address and port number of the remote endofthesocket.Analogousto"Local Address."
第五列为外部的地址及端口。


State
Thestateofthesocket.Sincethere are no states in raw mode and usually no
states used in UDP, this column may be left blank. Normally this can be one of sev-
eral values:
第六列为socket的状态,通常仅仅有tcp的状态,状态值可能有ESTABLISHED,SYN_SENT,SYN_RECV FIN_WAIT1,FIN_WAIT2,TIME_WAIT等,详见下文。其中,最重要的是第六列。

ESTABLISHED     established
The socket has an established connection.
socket已经建立连接,表示处于连接的状态,一般认为有一个ESTABLISHED认为是一个服务的并发连接。这个连接状态在生产场景很重要,要重点关注。
SYN_SENT
The socket is actively attempting to establish a connection.
socket正在积极尝试建立一个连接,即处于发送后连接前的一个等待但未匹配进入连接的状态。
SYN_RECV
A connection request has been received from the network.
已经从网络上收到一个连接请求。

FIN_WAIT1
The socket is closed, and the connection is shutting down.
socket已关闭,连接正在或正要关闭。

FIN_WAIT2
Connectionisclosed,andthesocket is waiting for a shutdown from the remote end.
连接已关闭,并且socket正在等待远端结束。

TIME_WAIT
The socket is waiting after close to handle packets still in the network.
socket正在等待关闭处理仍在网络上的数据包,这个连接状态在生产场景很重要,要重点关注。

CLOSED The socket is not being used.| socket不在被占用了。
CLOSE_WAIT
The remote end has shutdown, waiting for the socket to close.
远端已经结束,等待socket关闭。

LAST_ACK
The remote end has shut down, and the socket is closed. Waiting for acknowl-edgement.|
远端已经结束,并且socket也已关闭,等待acknowl-edgement。
LISTEN Thesocketislisteningforincoming connections.Such sockets are not
included in the output unless you specify the --listening (-l) or --all (-a)
option.

socket正在监听连接请求。
CLOSING
Both sockets are shut down but we still don’t have all our data sent.
sockets关闭,但是我们仍旧没有发送数据。
UNKNOWN
The state of the socket is unknown
未知的状态。



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-353873-1-1.html 上篇帖子: centos7下安装MPlayer 下篇帖子: Linux下常见的解压缩方法 网络连接 信息
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表