手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux netstat 命令入门知识

[日期:2015-02-26] 来源:Linux社区  作者:kaifly [字体: ]

netstat 是Linux系统管理常用的一个命令,尤其是在进行网络相关问题排查的时候更是堪称‘瑞士***’。本人一直以来也只是对常用的几个选项如(a 、n、 p、 t、 u)等几个选项较为熟悉,但是对于netstat显示出来的连接的 状态信息,如下图

Linux netstat 命令入门知识

多数还了解的不够透彻,今天有时间,特此照着man文档加深一下理解。

Linux netstat命令详解 http://www.linuxidc.com/Linux/2012-12/75667.htm

使用netstat检测及监测网络连接  http://www.linuxidc.com/Linux/2014-09/106497.htm

Netstat 的10个基本用法 http://www.linuxidc.com/Linux/2014-01/94644.htm

Linux netstat命令 http://www.linuxidc.com/Linux/2013-06/85528.htm

Linux命令:service & netstat  http://www.linuxidc.com/Linux/2011-12/48395.htm

Linux下用netstat命令查看网络负载状况的一条语句 http://www.linuxidc.com/Linux/2011-08/41429.htm

LPI认证考试学习之Linux netstat 命令详解 http://www.linuxidc.com/Linux/2009-12/23197.htm

netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

SYNOPSIS(概要)
      netstat  [address_family_options(地址族选项)]  [--tcp|-t] [--udp|-u] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--sym-bolic|-N] [--extend|-e[--extend|-e]] [--timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c] [delay]
      netstat {--route|-r} [address_family_options] [--extend|-e[--extend|-e]]  [--verbose|-v]  [--numeric|-n]  [--numeric-hosts][--numeric-ports][--numeric-ports]  [--continu-ous|-c] [delay]
      netstat {--interfaces|-I|-i} [iface] [--all|-a] [--extend|-e] [--verbose|-v] [--program|-p] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continu-ous|-c] [delay]
      netstat {--groups|-g} [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
      netstat {--masquerade|-M} [--extend|-e] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
      netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--raw|-w] [delay]
      netstat {--version|-V}
      netstat {--help|-h}
      address_family_options:
      [--protocol={inet,unix,ipx,ax25,netrom,ddp}[,...]]  [--unix|-x] [--inet|--ip] [--ax25] [--ipx] [--netrom] [--ddp]
NOTE
      This program is obsolete.  Replacement for netstat is ss.  Replacement for netstat -r is ip route.  Replacement for netstat -i is ip -s link.  Replacement for netstat  -g
is ip maddr.
注:这个程序已经是是老旧的/废弃的了(但是依然很常用)。新版本的系统以ss命令来替代netstat,以ip route来替代netstat -r,以ip maddr来替代netstat -g。

DESCRIPTION(摘要)
      Netstat prints information about the Linux networking subsystem.  The type of information printed is controlled by the first argument, as follows:
    netstat 打印Linux网络子系统的信息,输出的信息样式由第一个参数来控制,如下:
(none)
      By  default,  netstat  displays  a  list  of  open sockets.  If you don’t specify any address families, then the active sockets of all configured address families will be
printed.
    (无参数)默认的,netstat显示所有系统套接字的列表。如果你不指定任何的地址族,所有的被配置的地址族的活动套接字将会被显示。
  --route , -r
      Display the kernel routing tables.
    显示内核路由表
  --groups , -g
      Display multicast group membership information for IPv4 and IPv6.
    显示IPv4和IPv6的多播组成员信息。
  --interfaces=iface , -I=iface , -i
      Display a table of all network interfaces, or the specified iface.
    显示所有网络接口的信息表,或者显示指定的接口
  --masquerade , -M
      Display a list of masqueraded connections.
    显示伪装的连接
  --statistics , -s
      Display summary statistics for each protocol.
    按照协议类型显示各协议的汇总信息


OPTIONS(选项)
  --verbose , -v
      Tell the user what is going on by being verbose. Especially print some useful information about unconfigured address families.
  --numeric , -n      Show numerical addresses instead of trying to determine symbolic host, port or user names.
  --numeric-hosts
      shows numerical host addresses but does not affect the resolution of port or user names.
  --numeric-ports
      shows numerical port numbers but does not affect the resolution of host or user names.
  --numeric-users
      shows numerical user IDs but does not affect the resolution of host or port names.
  --protocol=family , -A (协议族类型)
      Specifies the address families (perhaps better described as low level protocols) for which connections are to be shown.  family is a comma (’,’) separated list of address
family keywords like inet, unix, ipx, ax25, netrom, and ddp.  This has the same effect as using the --inet, --unix (-x), --ipx, --ax25, --netrom, and --ddp options.
      The address family inet includes raw, udp and tcp protocol sockets.

  -c, --continuous
      This will cause netstat to print the selected information every second continuously(连续不断的).
  -e, --extend
      Display additional information.  Use this option twice for maximum detail.
    显示更多的信息,用-ee 显示最多的信息
  -o, --timers
      Include information related to networking timers.
    显示和网络计时器相关的信息
  -p, --program
      Show the PID and name of the program to which each socket belongs.
    显示连接所属的PID和程序名称
  -l, --listening
      Show only listening sockets.  (These are omitted by default.)
    只显示监听的套接字(端口)默认是忽略这个选项的
  -a, --all
      Show both listening and non-listening (for TCP this means established connections) sockets.  With the --interfaces option, show interfaces that are not marked
  -F
      Print routing information from the FIB.  (This is the default.)
  -C
      Print routing information from the route cache.
  -Z --context
      If SELinux enabled print SELinux context.
  -T --notrim
      Stop trimming long addresses.
  delay
      Netstat will cycle printing through statistics every delay seconds

接下来是重头戏了,深入理解netstat的输出,这里才是实际能帮助我们、给我们提示的地方。

更多详情见请继续阅读下一页的精彩内容http://www.linuxidc.com/Linux/2015-02/114108p2.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款