netstat详解

  • 前言:

  大家好,我是handsomecui:欢迎大家访问我的博客,欢迎留言拍砖,转载请注明地址:http://www.cnblogs.com/handsomecui/

  • 概念

   Netstat是在内核中访问网络连接状态及其相关信息的程序,它能提供TCP连接,TCP和UDP监听,进程内存管理的相关报告。      -----来自RFC(维基百科)标准解释

  • 参数定义
  -a 显示所有socket,包括已建立的连接(ESTABLISHED),也包括监听连接请求(LISTENING)的那些连接。
  -c 每隔1秒就重新显示一遍,直到用户中断它。
  -i 显示所有网络接口的信息,格式“netstat -i”。
  -l 仅列出有在 Listen (监听) 的服務状态
  -n 以网络IP地址代替名称,显示所有已建立的有效连接。
  -r显示核心路由表,格式同“route -e”。
  -t 显示TCP协议的连接情况
  -u 显示UDP协议的连接情况。
  -v 显示正在进行的工作。
  -p +name显示协议名查看某协议使用情况
  -b 显示在创建每个连接或侦听端口时涉及的可执行程序。
  -e 显示以太网统计。此选项可以与 -s 选项结合使用。
  -f 显示外部地址的完全限定域名(FQDN)。
  -o显示与每个连接相关的所属进程 ID。
  -s 显示每个协议的统计。
  -x 显示 NetworkDirect 连接、侦听器和共享端点。
  -y 显示所有连接的 TCP 连接模板。无法与其他选项结合使用。
  • 状态描述
  ESTABLISHED
          The socket has an established connection.
   SYN_SENT
          The socket is actively attempting to establish a connection.
   SYN_RECV
          A connection request has been received from the network.
   FIN_WAIT1
          The socket is closed, and the connection is shutting down.
   FIN_WAIT2
          Connection is closed, and the socket is waiting for  a  shutdown
          from the remote end.
   TIME_WAIT
          The socket is waiting after close to handle packets still in the
          network.
   CLOSE  The socket is not being used.
   CLOSE_WAIT
          The remote end has shut down, waiting for the socket to close.
   LAST_ACK
          The remote end has shut down, and the socket is closed.  Waiting
          for acknowledgement.
   LISTEN The  socket is listening for incoming connections.  Such sockets
          are  not  included  in  the  output  unless  you   specify   the
          --listening (-l) or --all (-a) option.
   CLOSING
          Both  sockets are shut down but we still don't have all our data
          sent.
   UNKNOWN
          The state of the socket is unknown.
 
posted @ 2018-04-10 17:44  handsomecui  阅读(1049)  评论(0编辑  收藏  举报