个人工具

“Quick HOWTO : Ch04 : Simple Network Troubleshooting/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
<p><span class="fck_mw_template">{{Translation}}</span><span class="fck_mw_template">{{From|http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch04_:_Simple_Network_Troubleshooting}}</span> <span class="fck_mw_template">{{Translator|Apshai}}</span> <span class="fck_mw_template">{{Languages|Quick HOWTO : Ch04 : Simple Network Troubleshooting}}</span>
+
{{Translation}}
</p>
+
<h1> Introduction简介 </h1>
+
<p>You will eventually find yourself trying to fix a network related problem which usually appears in one of two forms. The first is slow response times from the remote server, and the second is a complete lack of connectivity. These symptoms can be caused by:
+
</p><p>你最终会发现你试图修正的网络问题经常以两种形式出现。第一种是来自远程服务器的慢速响应,第二种是完全失去连接。这些症状会是由一下原因引起的:<br />
+
</p>
+
== Sources of Network Slowness 网络慢的根源<br> ==
+
  
* NIC duplex and speed incompatibilities&nbsp; 网卡的双工和速度的不兼容<br>
+
{{From|http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch04_:_Simple_Network_Troubleshooting}}
* Network congestion 网络涌堵<br>
+
* Poor routing 路由问题<br>
+
* Bad cabling&nbsp; 线缆问题<br>
+
* Electrical interference 电阻,电波干扰<br>
+
* An overloaded server at the remote end of the connection 远端服务器负载过重<br>
+
* Misconfigured DNS (Covered in Chapter 18, "&lt;a href="Quick HOWTO&nbsp;: Ch18&nbsp;: Configuring DNS"&gt;Configuring DNS&lt;/a&gt;" and Chapter 19, "&lt;a href="Quick HOWTO&nbsp;: Ch19&nbsp;: Dynamic DNS"&gt;Dynamic DNS&lt;/a&gt;")DNs配置问题(参考18章“配置DNS”和19章“动态DNS”)
+
  
<h2> Sources of a Lack of Connectivity 连接丢失的根源<br /> </h2>
+
{{Translator|Apshai}}
<p>All sources of slowness can become so severe that connectivity is lost. Additional sources of disconnections are:
+
 
</p><p>所有网络慢的原因严重时都可以导致连接丢失。额外的原因包括:
+
{{Languages|Quick HOWTO : Ch04 : Simple Network Troubleshooting}}
</p>
+
 
<ul><li> Power failures 电源问题<br />
+
 
</li><li> The remote server or an application on the remote server being shut down. 远端的服务器或程序被关掉<br />
+
= 简介 =
</li></ul>
+
你最终会发现你试图修正的网络问题经常以两种形式出现。第一种是来自远程服务器的慢速响应,第二种是完全失去连接。这些症状会是由一下原因引起的:
<p>We discuss how to isolate these problems and more in the following sections.我们会讨论如何隔离这些问题,在以後的章节中会有更详细的讨论。
+
 
</p>
+
== 网络慢的根源 ==
<h2> Doing Basic Cable and Link Tests做一些基本的连接测试 </h2>
+
 
<p>Your server won't be able to communicate with any other device on your network unless the NIC's "link" light is on. This indicates that the connection between your server and the switch/router is functioning correctly.
+
* 网卡的双工和速度的不兼容
</p><p>你的服务器只有在网卡的连接指示灯亮的时候才可以和其他设备进行通信。这个指示灯表明服务器和交换机或路由器的连接是正常的。<br />
+
* 网络涌堵
</p><p>In most cases a lack of link is due to the wrong cable type being used. As described in Chapter 2, "<a href="Quick HOWTO : Ch02 : Introduction to Networking">Introduction to Networking</a>", there are two types of Ethernet cables crossover and straight-through. Always make sure you are using the correct type.
+
* 路由问题
</p><p>在大多数情况下,网络不通是因为用了错误的线缆所致。正如我们在第二章描述的,存在两种线:交叉线和直通线。一定要确保你使用了正确的线缆。<br />
+
* 线缆问题
</p><p>Other sources of link failure include:其他的一些原因包括:
+
* 电阻,电波干扰
</p>
+
* 远端服务器负载过重
<ul><li> The cables are bad.线缆坏了。
+
* DNs配置不当 (参考第18章 "[[Quick HOWTO : Ch18 : Configuring DNS|配置DNS]]" 和19章, "[[Quick HOWTO : Ch19 : Dynamic DNS|动态DNS]]")
</li><li> The switch or router to which the server is connected is powered down.服务器连接的交换机或路由器停掉了。
+
 
</li><li> The cables aren't plugged in properly.线缆没有插好。
+
== 连接丢失的根源= ==
</li></ul>
+
 
<p>If you have an extensive network, investment in a battery-operated cable tester for basic connectivity testing is invaluable. More sophisticated models in the market will be able to tell you the approximate location of a cable break and whether an Ethernet cable is too long to be used.
+
所有网络慢的原因严重时都可以导致连接丢失。额外的原因包括:
</p><p>如果你有外网,投资买一个电池驱动的线缆测试仪是非常值得的。市面上一些好的模型可以告诉你线缆坏的大概位置以及用的线缆是否过长。
+
 
</p>
+
* 电源问题
<h1> Testing Your NIC测试你的网卡 </h1>
+
* 远端的服务器或程序被关掉
<p>It is always a good practice in troubleshooting to be versed in monitoring the status of your NIC card from the command line. The following sections introduce a few commands that will be useful.
+
 
</p><p>在排障的过程中,从命令行监视你网卡的状态是一个很好的习惯。下面的章节将会介绍一些非常有用的命令。<br />
+
我们会讨论如何隔离这些问题,在以後的章节中会有更详细的讨论。
</p>
+
 
<h2> Viewing Your Activated Interfaces查看你激活的网卡。 </h2>
+
==做一些基本的连接测试==
<p>The ifconfig command without any arguments gives you all the active interfaces on your system. Interfaces will not appear if they are shut down:
+
你的服务器只有在网卡的连接指示灯亮的时候才可以和其他设备进行通信。这个指示灯表明服务器和交换机或路由器的连接是正常的。
</p><p>ifconfig命令不加任何参数会显示你系统上活动的网卡。那些没有激活的网卡将不会被显示。<br />
+
 
</p>
+
在大多数情况下,网络不通是因为用了错误的线缆所致。正如我们在第二章描述的,存在两种线:交叉线和直通线。一定要确保你使用了正确的线缆。
<pre class="_fck_mw_lspace">[root@bigboy tmp]# ifconfig
+
 
</pre>
+
其他的一些原因包括:
<p><b>Note:</b> Interfaces will appear if they are activated, but have no link. We'll soon discuss how to determine the link status using commands.
+
 
</p><p>注意:那些被激活但没有连接的网卡也会被显示。我们待会讨论如何查看连接的状态。<br />
+
* 线缆坏了。
</p>
+
*服务器连接的交换机或路由器停掉了。
<h2> Viewing All Interfaces 查看所有的网卡。<br /> </h2>
+
*线缆没有插好。
<p>The ifconfig -a command provides all the network interfaces, whether they are functional or not. Interfaces that are shut down by the systems administrator or are nonfunctional will not show an IP address line and the word UP will not show in the second line of the output. This can be seen in the next examples:
+
 
</p><p>ifconfikg -a 会显示所有的网卡设备,不管他们是否被激活。那些没有被系统管理员激活或没有功用的网卡将不会显示ip地址这一行,同时UP这个词也不会在第二行的输出中显示。下面的例子说明了这个现象:
+
如果你有外网,投资买一个电池驱动的线缆测试仪是非常值得的。市面上一些好的模型可以告诉你线缆坏的大概位置以及用的线缆是否过长。
</p>
+
 
<ul><li> Shut Down Interface显示没有激活的网卡
+
=测试你的网卡 =
</li></ul>
+
在排障的过程中,从命令行监视你网卡的状态是一个很好的习惯。下面的章节将会介绍一些非常有用的命令。
<pre class="_fck_mw_lspace">wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
+
===查看你激活的网卡。 ==
 +
ifconfig命令不加任何参数会显示你系统上活动的网卡。那些没有激活的网卡将不会被显示。
 +
 
 +
[root@bigboy tmp]# ifconfig
 +
 
 +
注意:那些被激活但没有连接的网卡也会被显示。我们待会讨论如何查看连接的状态。<br />
 +
 
 +
==查看所有的网卡==
 +
ifconfikg -a 会显示所有的网卡设备,不管他们是否被激活。那些没有被系统管理员激活或没有功用的网卡将不会显示ip地址这一行,同时UP这个词也不会在第二行的输出中显示。下面的例子说明了这个现象:
 +
 
 +
*显示没有激活的网卡
 +
 
 +
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
 
  BROADCAST MULTICAST MTU:1500 Metric:1
 
  BROADCAST MULTICAST MTU:1500 Metric:1
 
  RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
 
  RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
第64行: 第64行:
 
  RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
 
  RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
 
  Interrupt:10 Memory:c88b5000-c88b6000
 
  Interrupt:10 Memory:c88b5000-c88b6000
</pre>
+
 
<p><br />
+
*Active Interface 激活的网卡
</p>
+
 
<ul><li> Active Interface 激活的网卡<br />
+
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
</li></ul>
+
<pre class="_fck_mw_lspace">wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
+
 
  inet addr:216.10.119.243 Bcast:216.10.119.255
 
  inet addr:216.10.119.243 Bcast:216.10.119.255
 
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
第77行: 第75行:
 
  RX bytes:180948 (176.7 Kb) TX bytes:166521 (162.6 Kb)
 
  RX bytes:180948 (176.7 Kb) TX bytes:166521 (162.6 Kb)
 
  Interrupt:10 Memory:c88b5000-c88b6000
 
  Interrupt:10 Memory:c88b5000-c88b6000
</pre>
 
<p><br />
 
</p>
 
<h2> Testing Link Status from the Command Line从命令行来测试连接的状态 </h2>
 
<p>Both the mii-tool and ethtool commands command will provide reports on the link status and duplex settings for supported NICs.
 
</p><p>When used without any switches, the mii-tool gives a very brief report. Use it with the -v switch because it provides more information on the supported autonegotiation speeds of the NIC and this can be useful in troubleshooting speed and duplex issues.
 
</p><p>The ethtool command provides much more information than mii-tool and should be your command of choice, especially because mii-tool will be soon deprecated in Linux. In both of the following examples the NICs are operating at 100Mbps, full duplex and the link is ok.
 
</p><p>mii-tool和ethtool这两个命令会提供一个连接状态和双工设置的报告。
 
</p><p>mii-tool不加任何参数会提供一个简短的报告。当加上-v这个参数时,因为它提供了关于网卡是否支持全自动等更详细的信息,这在解决网络速度和双工等排障的过程中非常有用。
 
</p><p>ethtool命令相对mii-tool命令提供了更详细的信息,尤其是mii-tool可能将来在linux中不再得到支持的情况下,ethtool应该成为你的不二选择。
 
</p><p>下面的两个例子中,网卡都是100Mbps的传输速度,全双工,连接状态是正常的。<br />
 
</p>
 
<h3> Link Status Output from mii-tool mii-tool的连接状态输出<br /> </h3>
 
<pre class="_fck_mw_lspace">[root@bigboy tmp]# mii-tool -v
 
  
eth0: 100 Mbit, full duplex, link ok
+
==从命令行来测试连接的状态==
 +
mii-tool和ethtool这两个命令会提供一个连接状态和双工设置的报告。
 +
 
 +
mii-tool不加任何参数会提供一个简短的报告。当加上-v这个参数时,因为它提供了关于网卡是否支持全自动等更详细的信息,这在解决网络速度和双工等排障的过程中非常有用。
 +
 
 +
ethtool命令相对mii-tool命令提供了更详细的信息,尤其是mii-tool可能将来在linux中不再得到支持的情况下,ethtool应该成为你的不二选择。
 +
 
 +
下面的两个例子中,网卡都是100Mbps的传输速度,全双工,连接状态是正常的。
 +
 
 +
===mii-tool的连接状态输出===
 +
[root@bigboy tmp]# mii-tool -v
 +
 +
eth0: 100 Mbit, full duplex, link ok
 
  product info: Intel 82555 rev 4
 
  product info: Intel 82555 rev 4
 
  basic mode: 100 Mbit, full duplex
 
  basic mode: 100 Mbit, full duplex
第99行: 第95行:
 
  advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
 
  advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
 
  link partner: 100baseTx-HD
 
  link partner: 100baseTx-HD
 +
 +
[root@bigboy tmp]#
  
[root@bigboy tmp]#
+
===Link Status Output from ethtool ethtool的连接状态输出===
</pre>
+
[root@bigboy tmp]# ethtool eth0
<h3> Link Status Output from ethtool ethtool的连接状态输出<br /> </h3>
+
<pre class="_fck_mw_lspace">[root@bigboy tmp]# ethtool eth0
+
Settings for eth0:
 
+
Settings for eth0:
+
 
  Supported ports: [ TP MII ]
 
  Supported ports: [ TP MII ]
 
  Supported link modes: 10baseT/Half 10baseT/Full
 
  Supported link modes: 10baseT/Half 10baseT/Full
第123行: 第119行:
 
  Current message level: 0x00000007 (7)
 
  Current message level: 0x00000007 (7)
 
  Link detected: yes
 
  Link detected: yes
[root@bigboy tmp]#
+
[root@bigboy tmp]#
</pre>
+
 
<p><br />
+
==查看网卡的错误信息==
</p>
+
错误是网络慢的常见标志,这可能是由不合适的网卡配置和带宽的过度利用造成的。只要在可能的情况下这都应该得到纠正。超过0.5%的错误率会导致显着的缓慢。
<h2> Viewing NIC Errors 查看网卡的错误信息<br /> </h2>
+
===Ifconfig的错误输出===
<p>Errors are a common symptom of slow connectivity due to poor configuration or excessive bandwidth utilization. They should always be corrected whenever possible. Error rates in excess of 0.5% can result in noticeable sluggishness.
+
ifconfig命令显示了overrun,carrier,dropped packjet和frame errors的数量
</p><p>错误是网络慢的常见标志,这可能是由不合适的网卡配置和带宽的过度利用造成的。只要在可能的情况下这都应该得到纠正。超过0.5%的错误率会导致显着的缓慢。<br />
+
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
</p>
+
<h3> Ifconfig Error Output Ifconfig的错误输出<br /> </h3>
+
<p>The ifconfig command also shows the number of overrun, carrier, dropped packet and frame errors.
+
</p><p>ifconfig命令显示了overrun,carrier,dropped packjet和frame errors的数量<br />
+
</p>
+
<pre class="_fck_mw_lspace">wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
+
 
  BROADCAST MULTICAST MTU:1500 Metric:1
 
  BROADCAST MULTICAST MTU:1500 Metric:1
 
  RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
 
  RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
第142行: 第132行:
 
  RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
 
  RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
 
  Interrupt:10 Memory:c88b5000-c88b6000
 
  Interrupt:10 Memory:c88b5000-c88b6000
</pre>
+
 
<h3> ethtool Error Output ethtool的错误输出<br /> </h3>
+
===ethtool的错误输出===
<p>The ethtool command can provide a much more detailed report when used with the -S switch.
+
ethtool命令当加上-S参数时提供了更详细的信息。<br />
</p><p>ethtool命令当加上-S参数时提供了更详细的信息。<br />
+
 
</p>
+
[root@probe-001 root]# ethtool -S eth0
<pre class="_fck_mw_lspace">[root@probe-001 root]# ethtool -S eth0
+
NIC statistics:
NIC statistics:
+
 
  rx_packets: 1669993
 
  rx_packets: 1669993
 
  tx_packets: 627631
 
  tx_packets: 627631
第178行: 第167行:
 
  tx_tco_packets: 0
 
  tx_tco_packets: 0
 
  rx_tco_packets: 0
 
  rx_tco_packets: 0
[root@probe-001 root]#
+
[root@probe-001 root]#
</pre>
+
 
<h2> netstat Error Output </h2>
+
==netstat Error Output==
<p>The netstat command is very versatile and can provide a limited report when used with the -i switch. This is useful for systems where mii-tool or ethtool are not available.
+
netstat命令是有非常多用途的命令,当加上-i参数时可以提供一个简短的报告。这在系统缺少mii-tool和ethtool工具时是非常有用的。
</p><p>netstat命令是有非常多用途的命令,当加上-i参数时可以提供一个简短的报告。这在系统缺少mii-tool和ethtool工具时是非常有用的。<br />
+
</p>
+
 
<pre class="_fck_mw_lspace">[root@bigboy tmp]# netstat -i
 
<pre class="_fck_mw_lspace">[root@bigboy tmp]# netstat -i
 
Kernel Interface table
 
Kernel Interface table
第192行: 第179行:
 
[root@bigboy tmp]#
 
[root@bigboy tmp]#
 
</pre>
 
</pre>
<h3> Possible Causes of Ethernet Errors </h3>
+
===Possible Causes of Ethernet Errors===
<p><b>Collisions:</b> Signifies when the NIC card detects itself and another server on the LAN attempting data transmissions at the same time. Collisions can be expected as a normal part of Ethernet operation and are typically below 0.1% of all frames sent. Higher error rates are likely to be caused by faulty NIC cards or poorly terminated cables.
+
<b>Collisions:</b> Signifies when the NIC card detects itself and another server on the LAN attempting data transmissions at the same time. Collisions can be expected as a normal part of Ethernet operation and are typically below 0.1% of all frames sent. Higher error rates are likely to be caused by faulty NIC cards or poorly terminated cables.
</p><p><b>Single Collisions:</b> The Ethernet frame went through after only one collision
+
 
 +
<b>Single Collisions:</b> The Ethernet frame went through after only one collision
 
</p><p><b>Multiple Collisions:</b> The NIC had to attempt multiple times before successfully sending the frame due to collisions.
 
</p><p><b>Multiple Collisions:</b> The NIC had to attempt multiple times before successfully sending the frame due to collisions.
</p><p><b>CRC Errors:</b> Frames were sent but were corrupted in transit. The presence of CRC errors, but not many collisions usually is an indication of electrical noise. Make sure that you are using the correct type of cable, that the cabling is undamaged and that the connectors are securely fastened.
+
 
</p><p><b>Frame Errors:</b> An incorrect CRC and a non-integer number of bytes are received. This is usually the result of collisions or a bad Ethernet device.
+
<b>CRC Errors:</b> Frames were sent but were corrupted in transit. The presence of CRC errors, but not many collisions usually is an indication of electrical noise. Make sure that you are using the correct type of cable, that the cabling is undamaged and that the connectors are securely fastened.
 +
 
 +
<b>Frame Errors:</b> An incorrect CRC and a non-integer number of bytes are received. This is usually the result of collisions or a bad Ethernet device.
 
</p><p><b>FIFO and Overrun Errors:</b> The number of times that the NIC was unable of handing data to its memory buffers because the data rate the capabilities of the hardware. This is usually a sign of excessive traffic.
 
</p><p><b>FIFO and Overrun Errors:</b> The number of times that the NIC was unable of handing data to its memory buffers because the data rate the capabilities of the hardware. This is usually a sign of excessive traffic.
</p><p><b>Length Errors:</b> The received frame length was less than or exceeded the Ethernet standard. This is most frequently due to incompatible duplex settings.
+
 
 +
<b>Length Errors:</b> The received frame length was less than or exceeded the Ethernet standard. This is most frequently due to incompatible duplex settings.
 
</p><p><b>Carrier Errors:</b> Errors are caused by the NIC card losing its link connection to the hub or switch. Check for faulty cabling or faulty interfaces on the NIC and networking equipment.
 
</p><p><b>Carrier Errors:</b> Errors are caused by the NIC card losing its link connection to the hub or switch. Check for faulty cabling or faulty interfaces on the NIC and networking equipment.
</p>
 

2008年4月15日 (二) 11:35的版本


简介

你最终会发现你试图修正的网络问题经常以两种形式出现。第一种是来自远程服务器的慢速响应,第二种是完全失去连接。这些症状会是由一下原因引起的:

网络慢的根源

  • 网卡的双工和速度的不兼容
  • 网络涌堵
  • 路由问题
  • 线缆问题
  • 电阻,电波干扰
  • 远端服务器负载过重
  • DNs配置不当 (参考第18章 "配置DNS" 和19章, "动态DNS")

连接丢失的根源=

所有网络慢的原因严重时都可以导致连接丢失。额外的原因包括:

  • 电源问题
  • 远端的服务器或程序被关掉

我们会讨论如何隔离这些问题,在以後的章节中会有更详细的讨论。

做一些基本的连接测试

你的服务器只有在网卡的连接指示灯亮的时候才可以和其他设备进行通信。这个指示灯表明服务器和交换机或路由器的连接是正常的。

在大多数情况下,网络不通是因为用了错误的线缆所致。正如我们在第二章描述的,存在两种线:交叉线和直通线。一定要确保你使用了正确的线缆。

其他的一些原因包括:

  • 线缆坏了。
  • 服务器连接的交换机或路由器停掉了。
  • 线缆没有插好。

如果你有外网,投资买一个电池驱动的线缆测试仪是非常值得的。市面上一些好的模型可以告诉你线缆坏的大概位置以及用的线缆是否过长。

测试你的网卡

在排障的过程中,从命令行监视你网卡的状态是一个很好的习惯。下面的章节将会介绍一些非常有用的命令。

=查看你激活的网卡。

ifconfig命令不加任何参数会显示你系统上活动的网卡。那些没有激活的网卡将不会被显示。

[root@bigboy tmp]# ifconfig

注意:那些被激活但没有连接的网卡也会被显示。我们待会讨论如何查看连接的状态。

查看所有的网卡

ifconfikg -a 会显示所有的网卡设备,不管他们是否被激活。那些没有被系统管理员激活或没有功用的网卡将不会显示ip地址这一行,同时UP这个词也不会在第二行的输出中显示。下面的例子说明了这个现象:

  • 显示没有激活的网卡
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
TX packets:2287 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
Interrupt:10 Memory:c88b5000-c88b6000
  • Active Interface 激活的网卡
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
inet addr:216.10.119.243 Bcast:216.10.119.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
TX packets:2295 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:180948 (176.7 Kb) TX bytes:166521 (162.6 Kb)
Interrupt:10 Memory:c88b5000-c88b6000

从命令行来测试连接的状态

mii-tool和ethtool这两个命令会提供一个连接状态和双工设置的报告。

mii-tool不加任何参数会提供一个简短的报告。当加上-v这个参数时,因为它提供了关于网卡是否支持全自动等更详细的信息,这在解决网络速度和双工等排障的过程中非常有用。

ethtool命令相对mii-tool命令提供了更详细的信息,尤其是mii-tool可能将来在linux中不再得到支持的情况下,ethtool应该成为你的不二选择。

下面的两个例子中,网卡都是100Mbps的传输速度,全双工,连接状态是正常的。

mii-tool的连接状态输出

[root@bigboy tmp]# mii-tool -v

eth0: 100 Mbit, full duplex, link ok
product info: Intel 82555 rev 4
basic mode: 100 Mbit, full duplex
basic status: link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link partner: 100baseTx-HD

[root@bigboy tmp]#

Link Status Output from ethtool ethtool的连接状态输出

[root@bigboy tmp]# ethtool eth0

Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
[root@bigboy tmp]#

查看网卡的错误信息

错误是网络慢的常见标志,这可能是由不合适的网卡配置和带宽的过度利用造成的。只要在可能的情况下这都应该得到纠正。超过0.5%的错误率会导致显着的缓慢。

Ifconfig的错误输出

ifconfig命令显示了overrun,carrier,dropped packjet和frame errors的数量

wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:D7
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
TX packets:2287 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:180948 (176.7 Kb) TX bytes:166377 (162.4 Kb)
Interrupt:10 Memory:c88b5000-c88b6000

ethtool的错误输出

ethtool命令当加上-S参数时提供了更详细的信息。

[root@probe-001 root]# ethtool -S eth0
NIC statistics:
rx_packets: 1669993
tx_packets: 627631
rx_bytes: 361714034
tx_bytes: 88228145
rx_errors: 0
tx_errors: 0
rx_dropped: 0
tx_dropped: 0
multicast: 0
collisions: 0
rx_length_errors: 0
rx_over_errors: 0
rx_crc_errors: 0
rx_frame_errors: 0
rx_fifo_errors: 0
rx_missed_errors: 0
tx_aborted_errors: 0
tx_carrier_errors: 0
tx_fifo_errors: 0
tx_heartbeat_errors: 0
tx_window_errors: 0
tx_deferred: 0
tx_single_collisions: 0
tx_multi_collisions: 0
tx_flow_control_pause: 0
rx_flow_control_pause: 0
rx_flow_control_unsupported: 0
tx_tco_packets: 0
rx_tco_packets: 0
[root@probe-001 root]#

netstat Error Output

netstat命令是有非常多用途的命令,当加上-i参数时可以提供一个简短的报告。这在系统缺少mii-tool和ethtool工具时是非常有用的。

[root@bigboy tmp]# 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 18976655 2 0 0 21343152 142 0 3 BMRU
eth1 1500 0 855154 0 0 0 15196620 0 0 0 BMRU
lo 16436 0 1784272 0 0 0 1784272 0 0 0 LRU
[root@bigboy tmp]#

Possible Causes of Ethernet Errors

Collisions: Signifies when the NIC card detects itself and another server on the LAN attempting data transmissions at the same time. Collisions can be expected as a normal part of Ethernet operation and are typically below 0.1% of all frames sent. Higher error rates are likely to be caused by faulty NIC cards or poorly terminated cables.

Single Collisions: The Ethernet frame went through after only one collision

</p>

Multiple Collisions: The NIC had to attempt multiple times before successfully sending the frame due to collisions. CRC Errors: Frames were sent but were corrupted in transit. The presence of CRC errors, but not many collisions usually is an indication of electrical noise. Make sure that you are using the correct type of cable, that the cabling is undamaged and that the connectors are securely fastened. Frame Errors: An incorrect CRC and a non-integer number of bytes are received. This is usually the result of collisions or a bad Ethernet device.

FIFO and Overrun Errors: The number of times that the NIC was unable of handing data to its memory buffers because the data rate the capabilities of the hardware. This is usually a sign of excessive traffic.

Length Errors: The received frame length was less than or exceeded the Ethernet standard. This is most frequently due to incompatible duplex settings.

Carrier Errors: Errors are caused by the NIC card losing its link connection to the hub or switch. Check for faulty cabling or faulty interfaces on the NIC and networking equipment.