1. 程式人生 > 其它 >linux檢視網路丟包情況 mtr網路連通性判斷工具

linux檢視網路丟包情況 mtr網路連通性判斷工具

3.1 先檢視硬體情況
一臺機器經常收到丟包的報警,先看看最底層的有沒有問題:

(1) 檢視工作模式是否正常

[root@localhost ~]# ethtool eth0 | egrep 'Speed|Duplex'
Speed: 1000Mb/s
Duplex: Full
 

(2) 檢視檢驗是否正常

[root@localhost ~]# ethtool -S eth0 | grep crc
rx_crc_errors: 0

Speed,Duplex,CRC 之類的都沒問題,基本可以排除物理層面的干擾。

 

 

 

3.2 通過 ifconfig 可以看到 overruns 是否一直增大
 

for i in `seq 1 100`; do ifconfig eth2 | grep RX | grep overruns; sleep 1; done
 

這裡一直增加

 

RX packets:346547657 errors:0 dropped:0 overruns:35345 frame:0
 

 

 

3.3 檢視buffer大小
 

可以通過ethtool來修改網絡卡的buffer size ,首先要網絡卡支援,我的伺服器是是INTEL 的1000M網絡卡,我們看看ethtool說明 

-g   –show-ringQueries the specified ethernet device for rx/tx ring parameter information.

-G   –set-ringChanges the rx/tx ring parameters of the specified ethernet device.
 

(1) 檢視當前網絡卡的buffer size情況

ethtool -g eth0
[root@localhost ~]# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 256
RX Mini: 0
RX Jumbo: 0
TX: 256
 

 

 

3.4 修改buffer size大小
ethtool -G eth0 rx 2048

ethtool -G eth0 tx 2048
 

[root@localhost ~]# ethtool -G eth0 rx 2048
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ethtool -G eth0 tx 2048
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 2048
RX Mini: 0
RX Jumbo: 0
TX: 2048

 

MTR是Linux平臺上一款非常好用的網路診斷工具,或者說網路連通性判斷工具,集成了ping,traceroute,nslookup的功能,用於診斷網路狀態很好用,可以用來判斷伺服器是否丟包

工具/原料

 
  • MTR
  • Linux(centos)

方法/步驟

 
  1. 1

    第一步:開啟Linux系統(本經驗以centos為例),我們判斷Linux上是否有MTR這個命令,輸入命令mtr -v,可以檢視mtr的版本資訊,如果出現下圖字樣為未安裝

  2. 2

    第二步:安裝mtr,我們通過系統自帶的yum命令來安裝,輸入yum install mtr -y回車後自動安裝,出現Complete!即表示安裝成功

  3. 3

    第三步:我們通過mtr來檢視是否丟包,這裡我們用到2個引數

    -n  不用主機解釋

    --report  結果顯示,並不動態顯示。

    輸入mtr -n --report www.qq.com回車就可以看到中間是否丟包了,其中loss%為丟包率