灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:2253回复:0

linux中使用netstat命令

楼主#
更多 发布于:2011-12-24 17:39
Netstat用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。
 
监控系统资源时较长用的命令为:(查看tcp连接的连接状态)
 
 
 
netstat -n -c |grep tcp


其参数说明:
 
 
 
        -r, --route                display routing table
 
        -I, --interfaces=[<Iface>] display interface table for <Iface>
 
        -i, --interfaces           display interface table
 
        -g, --groups               display multicast group memberships
 
        -s, --statistics           display networking statistics (like SNMP)
 
        -M, --masquerade           display masqueraded connections
 
 
 
        -v, --verbose              be verbose
 
        -n, --numeric              don't resolve names
 
        --numeric-hosts            don't resolve host names
 
        --numeric-ports            don't resolve port names
 
        --numeric-users            don't resolve user names
 
        -N, --symbolic             resolve hardware names
 
        -e, --extend               display other/more information
 
        -p, --programs             display PID/Program name for sockets
 
        -c, --continuous           continuous listing
 
 
 
        -l, --listening            display listening server sockets
 
        -a, --all, --listening     display all sockets (default: connected)
 
        -o, --timers               display timers
 
        -F, --fib                  display Forwarding Information Base (default)
 
        -C, --cache                display routing cache instead of FIB
 
        -T, --notrim               stop trimming long addresses
 
        -Z, --context              display SELinux security context for sockets
 
 
 
 
 
 
 
其中的状态大概有以下几种:
 
 
 
  CLOSED:无连接是活动的或正在进行
 
  LISTEN:服务器在等待进入呼叫
 
  SYN_RECV:一个连接请求已经到达,等待确认
 
  SYN_SENT:应用已经开始,打开一个连接
 
  ESTABLISHED:正常数据传输状态
 
  FIN_WAIT1:应用说它已经完成
 
  FIN_WAIT2:另一边已同意释放
 
  ITMED_WAIT:等待所有分组死掉
 
  CLOSING:两边同时尝试关闭
 
  TIME_WAIT:另一边已初始化一个释放
 
  LAST_ACK:等待所有分组死掉
 
 
 
摘自 rital的专栏


喜欢0 评分0
游客

返回顶部