netstat命令

[root@TA30-53 creditcc2.0]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp    10420      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp        1      0 TA30-53.local:56815         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp    10420      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:60483         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    10700      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:38710         10.100.30.97:afs3-callback  ESTABLISHED 
tcp    10420      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 
tcp    10420      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10420      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10700      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 
tcp        0    404 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427 


netstat的输出结果分为两个部分:

Active Internet connections,有源TCP连接,"Recv-Q"和"Send-Q"指%0A的是接收队列和发送队列。这些数字一般都是0。如果不是则表示软件包正在队列中堆积。
Active UNIX domain sockets,有源Unix域套接口(和网络套接字一样,但是只能用于本机通信,性能可以提高一倍)。

Proto 显示连接使用的协议

RefCnt 连接到本套接口上的进程号

Types 套接口的类型

State 套接口当前的状态

Path 连接到套接口的其它进程使用的路径名

常见参数

-a (all) 显示所有选项,默认不显示LISTEN相关
-t (tcp) 仅显示tcp相关选项
-u (udp 仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字
-l 仅列出有在 Listen (监听) 的服务状态
-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
-e 显示扩展信息,例如uid等
-s 按各个协议进行统计
-c 每隔一个固定时间,执行该netstat命令

提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到

1. 列出所有端口 (包括监听和未监听的)

列出所有端口 netstat -a

[root@TA30-53 creditcc2.0]# netstat -a|more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:mxi               *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN      
tcp    10520      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp    10520      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10520      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    10790      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10520      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp    10520      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10520      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10520      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:37674         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10520      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
--More--

列出所有 tcp 端口 netstat -at

[root@TA30-53 creditcc2.0]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:mxi               *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN      
tcp    10540      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    10810      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:37674         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 
tcp        1      0 TA30-53.local:40876         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp    10540      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 
tcp        1      0 TA30-53.local:52319         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 
tcp    10540      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10540      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10810      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 
tcp        0    308 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:6060          10.108.22.231:61616         TIME_WAIT   
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 

列出所有 udp 端口 netstat -au

[root@TA30-53 creditcc2.0]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
udp        0      0 *:827                       *:*                                     
udp        0      0 localhost:853               *:*                                     
udp        0      0 *:sunrpc                    *:*                                     
udp        0      0 *:35826                     *:*    

2. 列出所有处于监听状态的 Sockets

只显示监听端口 netstat -l
[root@TA30-53 creditcc2.0]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:mxi               *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN      
udp        0      0 *:827                       *:*                                     
udp        0      0 localhost:853               *:*                                     
udp        0      0 *:sunrpc                    *:*                                     
udp        0      0 *:35826                     *:*                                     
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket

只列出所有监听 tcp 端口 netstat -lt

[root@TA30-53 creditcc2.0]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:mxi               *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN  


只列出所有监听 udp 端口 netstat -lu

[root@TA30-53 creditcc2.0]# netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
udp        0      0 *:827                       *:*                                     
udp        0      0 localhost:853               *:*                                     
udp        0      0 *:sunrpc                    *:*                                     
udp        0      0 *:35826                     *:*  


只列出所有监听 UNIX 端口 netstat -lx
[root@TA30-53 creditcc2.0]# netstat -lx
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket

3. 显示每个协议的统计信息

显示所有端口的统计信息 netstat -s

[root@TA30-53 creditcc2.0]# netstat -s
Ip:
    4362089 total packets received
    0 forwarded
    0 incoming packets discarded
    4362088 incoming packets delivered
    4386790 requests sent out
Icmp:
    156 ICMP messages received
    1 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 63
        echo requests: 44
        echo replies: 49
    387 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 73
        echo request: 270
        echo replies: 44
IcmpMsg:
        InType0: 49
        InType3: 63
        InType8: 44
        OutType0: 44
        OutType3: 73
        OutType8: 270
Tcp:
    7899 active connections openings
    17253 passive connection openings
    1680 failed connection attempts
    316 connection resets received
    70 connections established
    4217718 segments received
    4227109 segments send out
    14656 segments retransmited
    0 bad segments received.
    902 resets sent
Udp:
    144130 packets received
    73 packets to unknown port received.
    0 packet receive errors
    144638 packets sent
UdpLite:
TcpExt:
    98 invalid SYN cookies received
    2030 packets pruned from receive queue because of socket buffer overrun
    21648 TCP sockets finished time wait in fast timer
    9870 delayed acks sent
    4 delayed acks further delayed because of locked socket
    Quick ack mode was activated 1182 times
    892951 packets directly queued to recvmsg prequeue.
    2147 packets directly received from backlog
    234244612 packets directly received from prequeue
    1164729 packets header predicted
    750952 packets header predicted and directly queued to user
    99106 acknowledgments not containing data received
    2287488 predicted acknowledgments
    121 times recovered from packet loss due to SACK data
    TCPDSACKUndo: 87
    336 congestion windows recovered after partial ack
    303 TCP data loss events
    TCPLostRetransmit: 2
    53 timeouts after SACK recovery
    114 timeouts in loss state
    324 fast retransmits
    19 forward retransmits
    1843 retransmits in slow start
    2971 other TCP timeouts
    56 sack retransmits failed
    116510 packets collapsed in receive queue due to low socket buffer
    1186 DSACKs sent for old packets
    930 DSACKs received
    2 DSACKs for out of order packets received
    4 connections reset due to unexpected data
    224 connections reset due to early user close
    2002 connections aborted due to timeout
    TCPDSACKIgnoredOld: 4
    TCPDSACKIgnoredNoUndo: 406
    TCPSpuriousRTOs: 18
    TCPSackShifted: 281
    TCPSackMerged: 729
    TCPSackShiftFallback: 772
    TCPChallengeACK: 5
    TCPWantZeroWindowAdv: 10844
IpExt:
    InMcastPkts: 1
    InOctets: 2592446896
    OutOctets: 590562315
    InMcastOctets: 36

显示 TCP 或 UDP 端口的统计信息 netstat -st 或 -su

[root@TA30-53 creditcc2.0]# netstat -st
IcmpMsg:
    InType0: 49
    InType3: 63
    InType8: 44
    OutType0: 44
    OutType3: 73
    OutType8: 270
Tcp:
    7900 active connections openings
    17253 passive connection openings
    1680 failed connection attempts
    316 connection resets received
    70 connections established
    4218164 segments received
    4227555 segments send out
    14656 segments retransmited
    0 bad segments received.
    902 resets sent
UdpLite:
TcpExt:
    98 invalid SYN cookies received
    2030 packets pruned from receive queue because of socket buffer overrun
    21648 TCP sockets finished time wait in fast timer
    9871 delayed acks sent
    4 delayed acks further delayed because of locked socket
    Quick ack mode was activated 1182 times
    892954 packets directly queued to recvmsg prequeue.
    2147 packets directly received from backlog
    234245075 packets directly received from prequeue
    1164750 packets header predicted
    750954 packets header predicted and directly queued to user
    99109 acknowledgments not containing data received
    2287755 predicted acknowledgments
    121 times recovered from packet loss due to SACK data
    TCPDSACKUndo: 87
    336 congestion windows recovered after partial ack
    303 TCP data loss events
    TCPLostRetransmit: 2
    53 timeouts after SACK recovery
    114 timeouts in loss state
    324 fast retransmits
    19 forward retransmits
    1843 retransmits in slow start
    2971 other TCP timeouts
    56 sack retransmits failed
    116510 packets collapsed in receive queue due to low socket buffer
    1186 DSACKs sent for old packets
    930 DSACKs received
    2 DSACKs for out of order packets received
    4 connections reset due to unexpected data
    224 connections reset due to early user close
    2002 connections aborted due to timeout
    TCPDSACKIgnoredOld: 4
    TCPDSACKIgnoredNoUndo: 406
    TCPSpuriousRTOs: 18
    TCPSackShifted: 281
    TCPSackMerged: 729
    TCPSackShiftFallback: 772
    TCPChallengeACK: 5
    TCPWantZeroWindowAdv: 10844
IpExt:
    InMcastPkts: 1
    InOctets: 2592475279
    OutOctets: 590590032
    InMcastOctets: 36
[root@TA30-53 creditcc2.0]# netstat -su
IcmpMsg:
    InType0: 49
    InType3: 63
    InType8: 44
    OutType0: 44
    OutType3: 73
    OutType8: 270
Udp:
    144138 packets received
    73 packets to unknown port received.
    0 packet receive errors
    144646 packets sent
UdpLite:
IpExt:
    InMcastPkts: 1
    InOctets: 2592498075
    OutOctets: 590614899
    InMcastOctets: 36

4. 在 netstat 输出中显示 PID 和进程名称 netstat -p

[root@TA30-53 creditcc2.0]# netstat -pt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp    10660      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10940      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:58164         10.100.30.97:afs3-callback  ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 11718/java          
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:57173         10.100.30.58:webcache       ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        1      0 TA30-53.local:43336         10.100.30.97:afs3-callback  CLOSE_WAIT  17805/java          
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp    10660      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp    10660      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 19343/java          
tcp    10940      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 19343/java          
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 11718/java          
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0   1416 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 25162/sshd          
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 17805/java          
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 17805/java  

5. 在 netstat 输出中不显示主机,端口和用户名 (host, port or user)

netstat -n 将会使用数字代替那些名称。同样可以加速输出,因为不用进行比对查询
[root@TA30-53 creditcc2.0]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 127.0.0.1:8036              0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:8005              0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:8006              0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:51049               0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8010                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8011                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:6060                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:2222                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:9081                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8090                0.0.0.0:*                   LISTEN      
tcp        0      0 10.143.128.165:9083         0.0.0.0:*                   LISTEN      
tcp    10830      0 10.143.128.165:52136        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51683        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51678        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52131        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60371        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52134        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60381        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60111        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51667        10.100.32.12:5672           ESTABLISHED 
tcp    11100      0 10.143.128.165:51836        10.143.224.22:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52127        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51671        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52132        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51685        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51676        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52130        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60385        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52125        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60383        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60382        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60374        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60368        10.143.224.12:1521          ESTABLISHED 
tcp        1      0 10.143.128.165:59221        10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 10.143.128.165:60379        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:33887        10.143.128.69:61616         ESTABLISHED 
tcp        0      0 10.143.128.165:38252        10.100.31.62:61616          ESTABLISHED 
tcp        0      0 10.143.128.165:51675        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51673        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:60367        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52138        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60375        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51679        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52139        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51677        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52129        10.143.224.22:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52121        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51681        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52126        10.143.224.22:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52135        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60366        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52128        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51680        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51674        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52124        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:6060         10.108.22.231:62001         TIME_WAIT   
tcp    10830      0 10.143.128.165:52123        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51670        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51684        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51682        10.100.32.12:5672           ESTABLISHED 
tcp    10830      0 10.143.128.165:52140        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60380        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52137        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51666        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:60384        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52122        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60373        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:51668        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:58060        10.100.32.12:27017          ESTABLISHED 
tcp        0      0 10.143.128.165:60378        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60369        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60376        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60377        10.143.224.12:1521          ESTABLISHED 
tcp    10830      0 10.143.128.165:52133        10.143.224.22:1521          ESTABLISHED 
tcp    11100      0 10.143.128.165:51837        10.143.224.22:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60370        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:52187        10.100.30.79:9080           TIME_WAIT   
tcp        0      0 10.143.128.165:60112        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:60372        10.143.224.12:1521          ESTABLISHED 
tcp        0      0 10.143.128.165:33884        10.143.128.69:61616         ESTABLISHED 
tcp        1      0 10.143.128.165:43416        10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 10.143.128.165:51664        10.100.32.12:5672           ESTABLISHED 
tcp        0    676 10.143.128.165:2222         10.108.22.231:61289         ESTABLISHED 
tcp        0      0 10.143.128.165:51669        10.100.32.12:5672           ESTABLISHED 
tcp        0      0 10.143.128.165:51672        10.100.32.12:5672           ESTABLISHED 
udp        0      0 0.0.0.0:827                 0.0.0.0:*                               
udp        0      0 127.0.0.1:853               0.0.0.0:*                               
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               
udp        0      0 0.0.0.0:35826               0.0.0.0:*                               
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427

如果只是不想让这三个名称中的一个被显示,使用以下命令

# netsat -a --numeric-ports
# netsat -a --numeric-hosts
# netsat -a --numeric-users

[root@TA30-53 creditcc2.0]# netstat -a --numeric-hosts
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 127.0.0.1:8036              0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:mxi               0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:8006              0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:51049               0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8010                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8011                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:6060                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:EtherNet/IP-1       0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:sunrpc              0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:9081                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8090                0.0.0.0:*                   LISTEN      
tcp        0      0 10.143.128.165:9083         0.0.0.0:*                   LISTEN      
tcp    10910      0 10.143.128.165:52136        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51683        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51678        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:57186        10.100.30.58:webcache       TIME_WAIT   
tcp    10910      0 10.143.128.165:52131        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60371        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52134        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60381        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60111        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51667        10.100.32.12:amqp           ESTABLISHED 
tcp    11190      0 10.143.128.165:51836        10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52127        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        1      0 10.143.128.165:53462        10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 10.143.128.165:51671        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52132        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51685        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51676        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52130        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60385        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52125        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60383        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60382        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60374        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60368        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 10.143.128.165:59221        10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 10.143.128.165:60379        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:33887        10.143.128.69:61616         ESTABLISHED 
tcp        0      0 10.143.128.165:38252        10.100.31.62:61616          ESTABLISHED 
tcp        0      0 10.143.128.165:51675        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51673        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:60367        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52138        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60375        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51679        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52139        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51677        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:6060         10.108.22.231:62098         ESTABLISHED 
tcp    10910      0 10.143.128.165:52129        10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52121        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51681        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52126        10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52135        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60366        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52128        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51680        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51674        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52124        10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52123        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51670        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51684        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51682        10.100.32.12:amqp           ESTABLISHED 
tcp    10910      0 10.143.128.165:52140        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60380        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52137        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51666        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:52192        10.100.30.79:glrpc          ESTABLISHED 
tcp        0      0 10.143.128.165:60384        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52122        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60373        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:51668        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:58060        10.100.32.12:27017          ESTABLISHED 
tcp        0      0 10.143.128.165:60378        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60369        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 10.143.128.165:47856        10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 10.143.128.165:60376        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60377        10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10910      0 10.143.128.165:52133        10.143.224.22:ncube-lm      ESTABLISHED 
tcp    11190      0 10.143.128.165:51837        10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60370        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:60112        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 10.143.128.165:58595        10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 10.143.128.165:60372        10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 10.143.128.165:33884        10.143.128.69:61616         ESTABLISHED 
tcp        1      0 10.143.128.165:43416        10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 10.143.128.165:51664        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.16:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 10.143.128.165:51669        10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 10.143.128.165:51672        10.100.32.12:amqp           ESTABLISHED 
udp        0      0 0.0.0.0:827                 0.0.0.0:*                               
udp        0      0 127.0.0.1:853               0.0.0.0:*                               
udp        0      0 0.0.0.0:sunrpc              0.0.0.0:*                               
udp        0      0 0.0.0.0:35826               0.0.0.0:*                               
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427   
[root@TA30-53 creditcc2.0]# netstat -a --numeric-ports
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:8005              *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:2222                      *:*                         LISTEN      
tcp        0      0 *:111                       *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN      
tcp    10920      0 TA30-53.local:52136         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:57186         10.100.30.58:8080           TIME_WAIT   
tcp    10920      0 TA30-53.local:52131         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52134         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:5672           ESTABLISHED 
tcp    11190      0 TA30-53.local:51836         10.143.224.22:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52127         10.143.224.22:1521          ESTABLISHED 
tcp        1      0 TA30-53.local:53462         10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 TA30-53.local:51671         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52132         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52130         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52125         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60368         10.143.224.12:1521          ESTABLISHED 
tcp        1      0 TA30-53.local:59221         10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 TA30-53.local:60379         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52138         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52139         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:6060          10.108.22.231:62098         TIME_WAIT   
tcp    10920      0 TA30-53.local:52129         10.143.224.22:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52121         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52126         10.143.224.22:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52135         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52128         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51674         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52124         10.143.224.22:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52123         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:5672           ESTABLISHED 
tcp    10920      0 TA30-53.local:52140         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52137         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:52192         10.100.30.79:9080           TIME_WAIT   
tcp        0      0 TA30-53.local:60384         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52122         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:1521          ESTABLISHED 
tcp        1      0 TA30-53.local:47856         10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 TA30-53.local:60376         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:1521          ESTABLISHED 
tcp    10920      0 TA30-53.local:52133         10.143.224.22:1521          ESTABLISHED 
tcp    11190      0 TA30-53.local:51837         10.143.224.22:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:1521          ESTABLISHED 
tcp        1      0 TA30-53.local:58595         10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 TA30-53.local:60372         10.143.224.12:1521          ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        1      0 TA30-53.local:43416         10.100.30.97:7001           CLOSE_WAIT  
tcp        0      0 TA30-53.local:51664         10.100.32.12:5672           ESTABLISHED 
tcp        0   1160 TA30-53.local:2222          10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:5672           ESTABLISHED 
tcp        0      0 TA30-53.local:51672         10.100.32.12:5672           ESTABLISHED 
udp        0      0 *:827                       *:*                                     
udp        0      0 localhost:853               *:*                                     
udp        0      0 *:111                       *:*                                     
udp        0      0 *:35826                     *:*                                     
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427   
[root@TA30-53 creditcc2.0]# netstat -a --numeric-users
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 localhost:8036              *:*                         LISTEN      
tcp        0      0 localhost:mxi               *:*                         LISTEN      
tcp        0      0 localhost:8006              *:*                         LISTEN      
tcp        0      0 *:8009                      *:*                         LISTEN      
tcp        0      0 *:51049                     *:*                         LISTEN      
tcp        0      0 *:8010                      *:*                         LISTEN      
tcp        0      0 *:8011                      *:*                         LISTEN      
tcp        0      0 *:6060                      *:*                         LISTEN      
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:9081                      *:*                         LISTEN      
tcp        0      0 *:8090                      *:*                         LISTEN      
tcp        0      0 TA30-53.local:9083          *:*                         LISTEN      
tcp    10920      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    11200      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:53462         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:59221         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:6060          10.108.22.231:62098         TIME_WAIT   
tcp    10920      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 
tcp    10920      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:52192         10.100.30.79:glrpc          TIME_WAIT   
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:47856         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10920      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    11200      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      0 TA30-53.local:58595         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        1      0 TA30-53.local:43416         10.100.30.97:afs3-callback  CLOSE_WAIT  
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 
udp        0      0 *:827                       *:*                                     
udp        0      0 localhost:853               *:*                                     
udp        0      0 *:sunrpc                    *:*                                     
udp        0      0 *:35826                     *:*                                     
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     7937   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11278  /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  2      [ ACC ]     STREAM     LISTENING     11404  @/var/run/hald/dbus-q5nM7wMygM
unix  2      [ ACC ]     STREAM     LISTENING     10723  /var/run/vmware/guestServicePipe
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     11399  @/var/run/hald/dbus-wFAmOnLQWS
unix  2      [ ACC ]     STREAM     LISTENING     11366  /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11088  /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     11863  /var/run/abrt/abrt.socket
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427  

6. 持续输出 netstat 信息

netstat 将每隔一秒输出网络信息

[root@TA30-53 creditcc2.0]# netstat -c
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp    10950      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    11220      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        1      1 TA30-53.local:53462         10.100.30.97:afs3-callback  LAST_ACK    
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:6060          10.108.22.231:62129         FIN_WAIT2   
tcp    10950      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      1 TA30-53.local:59221         10.100.30.97:afs3-callback  LAST_ACK    
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 
tcp    10950      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      1 TA30-53.local:47856         10.100.30.97:afs3-callback  LAST_ACK    
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10950      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    11220      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        1      1 TA30-53.local:58595         10.100.30.97:afs3-callback  LAST_ACK    
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:52193         10.100.30.79:glrpc          TIME_WAIT   
tcp        1      1 TA30-53.local:43416         10.100.30.97:afs3-callback  LAST_ACK    
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 
tcp        0   1808 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427   

7. 显示系统不支持的地址族 (Address Families)

[root@TA30-53 creditcc2.0]# netstat --verbose
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp    10960      0 TA30-53.local:52136         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51683         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51678         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52131         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60371         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52134         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60381         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60111         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51667         10.100.32.12:amqp           ESTABLISHED 
tcp    11230      0 TA30-53.local:51836         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52127         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51671         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52132         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51685         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51676         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52130         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60385         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52125         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60383         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60382         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60374         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60368         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60379         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33887         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:38252         10.100.31.62:61616          ESTABLISHED 
tcp        0      0 TA30-53.local:51675         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51673         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60367         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52138         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60375         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51679         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52139         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51677         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52129         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52121         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51681         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52126         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52135         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60366         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52128         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51680         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51674         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52124         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52123         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51670         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51684         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51682         10.100.32.12:amqp           ESTABLISHED 
tcp    10960      0 TA30-53.local:52140         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60380         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52137         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51666         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:60384         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52122         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60373         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:51668         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:58060         10.100.32.12:27017          ESTABLISHED 
tcp        0      0 TA30-53.local:60378         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60369         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60376         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60377         10.143.224.12:ncube-lm      ESTABLISHED 
tcp    10960      0 TA30-53.local:52133         10.143.224.22:ncube-lm      ESTABLISHED 
tcp    11230      0 TA30-53.local:51837         10.143.224.22:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60370         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60112         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:60372         10.143.224.12:ncube-lm      ESTABLISHED 
tcp        0      0 TA30-53.local:33884         10.143.128.69:61616         ESTABLISHED 
tcp        0      0 TA30-53.local:51664         10.100.32.12:amqp           ESTABLISHED 
tcp        0    228 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 
tcp        0      0 TA30-53.local:51669         10.100.32.12:amqp           ESTABLISHED 
tcp        0      0 TA30-53.local:51672         10.100.32.12:amqp           ESTABLISHED 
netstat: no support for `AF INET (sctp)' on this system.
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ]         DGRAM                    11429  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8411   @/org/kernel/udev/udevd
unix  8      [ ]         DGRAM                    10930  /dev/log
unix  2      [ ]         STREAM     CONNECTED     4850689 
unix  2      [ ]         STREAM     CONNECTED     4850104 
unix  2      [ ]         STREAM     CONNECTED     4840076 
unix  2      [ ]         STREAM     CONNECTED     4798484 
unix  2      [ ]         STREAM     CONNECTED     4798400 
unix  2      [ ]         DGRAM                    667040 
unix  2      [ ]         DGRAM                    11892  
unix  2      [ ]         DGRAM                    11865  
unix  2      [ ]         DGRAM                    11840  
unix  3      [ ]         STREAM     CONNECTED     11659  /var/run/acpid.socket
unix  3      [ ]         STREAM     CONNECTED     11658  
unix  3      [ ]         STREAM     CONNECTED     11653  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11651  
unix  3      [ ]         STREAM     CONNECTED     11548  @/var/run/hald/dbus-wFAmOnLQWS
unix  3      [ ]         STREAM     CONNECTED     11523  
unix  3      [ ]         STREAM     CONNECTED     11424  @/var/run/hald/dbus-q5nM7wMygM
unix  3      [ ]         STREAM     CONNECTED     11423  
unix  3      [ ]         STREAM     CONNECTED     11401  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11400  
unix  2      [ ]         DGRAM                    11368  
unix  3      [ ]         STREAM     CONNECTED     11290  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11289  
unix  3      [ ]         STREAM     CONNECTED     11283  
unix  3      [ ]         STREAM     CONNECTED     11282  
unix  2      [ ]         DGRAM                    11169  
unix  3      [ ]         DGRAM                    8428   
unix  3      [ ]         DGRAM                    8427   
netstat: no support for `AF IPX' on this system.
netstat: no support for `AF AX25' on this system.
netstat: no support for `AF X25' on this system.
netstat: no support for `AF NETROM' on this system.

8. 显示核心路由信息 netstat -r

[root@TA30-53 creditcc2.0]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.143.128.0    *               255.255.255.0   U         0 0          0 eth2
link-local      *               255.255.0.0     U         0 0          0 eth2
default         10.143.128.1    0.0.0.0         UG        0 0          0 eth2

注意: 使用 netstat -rn 显示数字格式,不查询主机名称。


9. 找出程序运行的端口

并不是所有的进程都能找到,没有权限的会不显示,使用 root 权限查看所有的信息
[root@TA30-53 creditcc2.0]# netstat -ap|grep ssh
tcp        0      0 *:EtherNet/IP-1             *:*                         LISTEN      28485/sshd          
tcp        0      0 TA30-53.local:EtherNet/IP-1 10.108.22.231:61289         ESTABLISHED 25162/sshd 

找出端口32893进程pid
[pso@localhost conf]$ netstat -anp|grep ':32893'
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 ::ffff:10.151.15.103:32893  :::*                        LISTEN      97927/java


找出运行在指定端口的进程
[root@TA30-53 creditcc2.0]# netstat -an|grep ':6060'
tcp        0      0 0.0.0.0:6060                0.0.0.0:*                   LISTEN 

10. 显示网络接口列表

[root@TA30-53 creditcc2.0]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth2       1500   0  5422062      0      0      0  4435994      0      0      0 BMRU
lo        65536   0      190      0      0      0      190      0      0      0 LRU

显示详细信息,像是 ifconfig 使用 netstat -ie
[root@TA30-53 creditcc2.0]# netstat -ie
Kernel Interface table
eth2      Link encap:Ethernet  HWaddr 00:50:56:A3:02:9B  
          inet addr:10.143.128.165  Bcast:10.143.128.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5422475 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4436404 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2715859558 (2.5 GiB)  TX bytes:654976728 (624.6 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:190 errors:0 dropped:0 overruns:0 frame:0
          TX packets:190 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:10411 (10.1 KiB)  TX bytes:10411 (10.1 KiB)

11. IP和TCP分析

查看连接某服务端口最多的的IP地址

netstat -nat | grep "10.143.128.165:6060" |awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -20 

 TCP各种状态列表

[root@TA30-53 creditcc2.0]# netstat -nat|awk '{print $6}'
established)
Foreign
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
LISTEN
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
FIN_WAIT2
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
TIME_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
CLOSE_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
CLOSE_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
CLOSE_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
CLOSE_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
CLOSE_WAIT
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
 先把状态全都取出来,然后使用uniq -c统计,之后再进行排序

[root@TA30-53 creditcc2.0]# netstat -nat|awk '{print $6}'|sort|uniq -c
      1 established)
     78 ESTABLISHED
      1 Foreign
      5 LAST_ACK
     13 LISTEN
      2 SYN_SENT
      2 TIME_WAIT

最后的命令如下:
[root@TA30-53 creditcc2.0]# netstat -nat|awk '{print $6}'|sort|uniq -c|sort -rn
     75 ESTABLISHED
     13 LISTEN
      2 TIME_WAIT
      2 SYN_SENT
      1 Foreign
      1 established)

你可能感兴趣的:(Linux)