NETSTAT - 查看网络运行情况。

NETSTAT - 查看网络运行情况。

Netstat的一些常用选项 
netstat -s——本选项能够按照各个协议分别显示其统计数据。如果你的应用程序(如Web浏览器)运行速度比较慢,或者不能显示Web页之

类的数据,那么你就可以用本选项来查看一下所显示的信息。你需要仔细查看统计数据的各行,找到出错的关键字,进而确定问题所在。 
netstat -e——本选项用于显示关于以太网的统计数据。它列出的项目包括传送的数据报的总字节数、错误数、删除数、数据报的数量和广

播的数量。这些统计数据既有发送的数据报数量,也有接收的数据报数量。这个选项可以用来统计一些基本的网络流量。 
netstat -r——本选项可以显示关于路由表的信息,类似于后面所讲使用route print命令时看到的 信息。除了显示有效路由外,还显示当

前有效的连接。 
netstat -a——本选项显示一个所有的有效连接信息列表,包括已建立的连接(ESTABLISHED),也包括监听连接请求(LISTENING)的那

些连接,断开连接(CLOSE_WAIT)或者处于联机等待状态的(TIME_WAIT)等
netstat -n——显示所有已建立的有效连接。
netstat支持用于显示活动或被动套接字的选项集。选项- t、- u、- w和-
x分别表示TCP、UDP、RAW和UNIX套接字连接。如果你另外还提供了一个-
a标记,还会显示出等待连接(也就是说处于监听模式)的套接字。这样就可以得到一份服务器清单,当前所有运行于系统中的所有服务器都

会列入其中。 
调用netstat -ta时,输出结果如下: 
[root@machine1 /]$ netstat -ta 
Active Internet connections (servers and established) 
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 2 210.34.6.89:telnet 210.34.6.96:2873 ESTABLISHED 
tcp 0 0 210.34.6.89:1165 210.34.6.84:netbios-ssn ESTABLISHED 
tcp 0 0 localhost.localdom:9001 localhost.localdom:1162 ESTABLISHED 
tcp 0 0 localhost.localdom:1162 localhost.localdom:9001 ESTABLISHED 
tcp 0 0 *:9001 *:* LISTEN 
tcp 0 0 *:6000 *:* LISTEN 
tcp 0 0 *:socks *:* LISTEN 
tcp 0 80 210.34.6.89:1161 210.34.6.10:netbios-ssn CLOSE 
上面的输出表明部分服务器处于等待接入连接状态。利用-
a选项的话,netstat还会显示出所有的套接字。注意根据端口号,可以判断出一条连接是否是外出连接。对呼叫方主机来说,列出的端口号

应该一直是一个
整数,而对众所周知服务(well known
service)端口正在使用中的被呼叫方来说,netstat采用的则是取自/etc/services文件的象征**名在随- i标记一起调用时, 

netstat将显示网络接口的当前配置特性。除此以外,如果调用时还带上-a选项,它还将输出内核中所有接口,并不只是当前配置的接口。

netstat-i的输出结果是这样的: 
[root@machine1 /]$ 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 
eth0 1500 0 787165 0 0 1 51655 0 0 0 BRU 
eth1 1500 0 520811 0 0 0 1986 0 0 0 BRU 
lo 3924 0 1943 0 0 0 43 0 0 0 LRU 
MTU和Met字段表示的是接口的MTU和度量值值;RX和TX这两列表示的是已经准确无误地收发了多少数据包( RX - OK / TX -
OK)、产生了多少错误(
RX-ERR/TX-ERR)、丢弃了多少包(RX-DRP/TX-DRP),由于误差而遗失了多少包(RX-OVR/TX-OVR);最后一列展示的是
为这个接口设置的标记,在利用ifconfig显示接口配置时,这些标记都采用一个字母。它们的说明如下: 
■ B 已经设置了一个广播地址。 
■ L 该接口是一个回送设备。 
■ M 接收所有数据包(混乱模式)。 
■ N 避免跟踪。 
■ O 在该接口上,禁用A R P。 
■ P 这是一个点到点链接。 
■ R 接口正在运行。 
■ U 接口处于“活动”状态。 ◆ 显示路由表 
在随- r标记一起调用n e t s t a t时,将显示内核路由表,就像我们利用r o u t e命令一样。产生的输出如下: 
[root@machine1 /]$ netstat -nr 
Kernel IP routing table 
Destination Gateway Genmask Flags MSS Window irtt Iface 
210.34.6.0 0.0.0.0 255.255.255.128 U 0 0 0 eth0 
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 
0.0.0.0 210.34.6.2 0.0.0.0 UG 0 0 0 eth0 
- n 选项令netstat以点分四段式的形式输出IP地址,而不是象征性的主机名和网络名。如果想避免通过网络查找地址(比如避开DNS或NIS

服务器),这一点是特别有用的。 
netstat输出结果中,第二列展示的是路由条目所指的网关,如果没有使用网关,就会出现一个星号(*)或者0.0.0.0;第三列展示路由的

概述,在
为具体的I P地址找出最恰当的路由时,内核将查看路由表内的所有条目,在对找到的路由与目标路由比较之前,将对I
P地址和genmask进行按位“与”计算;第四列显示了不同的标记,这些标记的说明如下: 
■ G 路由将采用网关。 
■ U 准备使用的接口处于“活动”状态。 
■ H 通过该路由,只能抵达一台主机。 
■ D 如果路由表的条目是由ICMP重定向消息生成的,就会设置这个标记。 
■ M 如果路由表条目已被ICMP重定向消息修改,就会设置这个标记。 
netstat输出结果的Iface显示该连接所用的物理网卡,如eth0表示用第一张,eth1表示用第二张。

Solaris平台下:

Field Description
name Device name of interface
Mtu Maximum transmission unit
Net Network Segment Address
address Network address of the device
ipkts Input packets
Ierrs Input errors
opkts Output Packets
Oerrs Output errors
collis Collisions
queue Number in the Queue

The information in Section 1 will help diagnose network problems when there is connectivity but response is slow.

Values to look at:

Collisions (Collis)
Output packets (Opkts)
Input errors (Ierrs)
Input packets (Ipkts)
The above values will give information to workout network collision rates as follows:

Network collision rate = Output collision / Output packets

For a switched network, the collisions should be 0.1 percent or less (see the Cisco web site as a reference) of the 

output packets. Excessive collisions could lead to the switch port the interface is plugged into to segment, or 

pull itself off-line, amongst other switch-related issues.

For the input error statistics:

Input Error Rate = Ierrs / Ipkts.

If the input error rate is high (over 0.25 percent), the host is excessively dropping packets. This could mean 

there is a mismatch of the duplex or speed  settings of the interface card and switch.  It could also imply a 

failed patch cable.

If ierrs or oerrs show an excessive amount of errors, more information can be found by examination of the netstat 

-s output.

For Sun systems, further information about a specific interface can be found by using the "-k" option for netstat. 

The output will give fuller statistics for the device, but this option is not mentioned in the netstat man page. 

More information can be found at http://sunsolve.sun.com.

Section 2

The information in Section 2 contains the protocol statistics.

Many performance problems associated with the network involve the retransmission of the TCP packets. For 

retransmission rate calculations click here.

To find the segment retransmission rate:

%segment-retrans=(tcpRetransSegs / tcpOutDataSegs) * 100

To find the byte retransmission rate:

%byte-retrans = ( tcpRetransBytes / tcpOutDataBytes ) * 100

Most network analyzers report TCP retransmissions as segments (frames) and not in bytes.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25105315/viewspace-763743/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25105315/viewspace-763743/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值