个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
=查看你激活的网卡。
第45行: 第45行:
 
=测试你的网卡 =
 
=测试你的网卡 =
 
在排障的过程中,从命令行监视你网卡的状态是一个很好的习惯。下面的章节将会介绍一些非常有用的命令。
 
在排障的过程中,从命令行监视你网卡的状态是一个很好的习惯。下面的章节将会介绍一些非常有用的命令。
===查看你激活的网卡。 ==
+
==查看你激活的网卡 ==
 
ifconfig命令不加任何参数会显示你系统上活动的网卡。那些没有激活的网卡将不会被显示。
 
ifconfig命令不加任何参数会显示你系统上活动的网卡。那些没有激活的网卡将不会被显示。
  

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.