linux下如何查看网卡速度
使用内核自带的工具 ethtool 可以查看和设置网卡的网速
1.ethtool的基本用法
ethtool ethX
ethtool –h
ethtool –i ethX
ethtool –d ethX
ethtool –r ethX
ethtool –S ethX
ethtool –s ethX
[speed 10
|100
|1000
]\
[duplex half
|full
]\
[autoneg on
|off
]\
[port tp
|aui
|bnc
|mii
]\
[phyad N
]\
[xcvr internal
|exteral
]\
[wol p
|u
|m
|b
|a
|g
|s
|d
...
]\
[sopass xx:yy:zz:aa:bb:cc
]\
[msglvl N
]
2.使用ethtool查询网卡信息
> ifconfig -a
ens37: flags
=4163
<UP,BROADCAST,RUNNING,MULTICAST
> mtu 1500
inet 192.168.136.205 netmask 255.255.255.0 broadcast 192.168.136.255
inet6 fe80::fd2e:62ff:920a:1bd4 prefixlen 64 scopeid 0x20
<link
>
ether 00:0c:29:ca:f5:45 txqueuelen 1000
(Ethernet
)
RX packets 3 bytes 729
(729.0 B
)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 30 bytes 2102
(2.0 KiB
)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
> ethtool ens37
Settings
for ens37:
Supported ports:
[ TP
]
Supported
link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised
link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off
(auto
)
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007
(7
)
drv probe
link
Link detected:
yes
我们来解释下看到的信息:
Supported ports :指支持的物理接口,这里仅包含TP 还可以有 Mii和 FIBRE 等类型。TP是指 双绞线(twisted pair)link modes :指连接模式,其实这是用两个参数组合构成的速度(speed)和双工(Duplex)
modespeed(Mb/s)deplex
10baseT/Half10half10baseT/Full10full100baseT/Hal100half100baseT/Full100full1000baseT/Full1000full
half 指 半双工; ful指全双工
Auto-negotiation :自动协商,有一个很值得思考的问题,千兆网卡就一定会跑千兆的速度吗?不一定。这个选项就是可以网线两端的网络设备相互协商来确定其运行模式(on就是开启)Speed 当前网卡设置的速度Duplex 当前网卡设置的双工模式Port 当前网卡连接的物理接口Link detected: 表示当前的连接状况 yes 就是连通
3.使用ethtool查询网卡驱动
> ethtool -i ens37
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:02:05.0
supports-statistics:
yes
supports-test:
yes
supports-eeprom-access:
yes
supports-register-dump:
yes
supports-priv-flags: no
> modinfo e1000
filename: /lib/modules/3.10.0-1127.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000/e1000.ko.xz
version: 7.3.21-k8-NAPI
license: GPL
description: Intel
(R
) PRO/1000 Network Driver
author: Intel Corporation,
<linux.nics@intel.com
>
retpoline: Y
rhelversion: 7.8
srcversion: BED5FAF40AE66C5A4A6AC4C
alias: pci:v00008086d00002E6Esv*sd*bc*sc*i*
alias: pci:v00008086d000010B5sv*sd*bc*sc*i*
...
...
4.使用ethtool查询网卡统计信息
> ethtool -S ens37
NIC statistics:
rx_packets: 23
tx_packets: 32
rx_bytes: 2622
tx_bytes: 2274
rx_broadcast: 0
tx_broadcast: 0
...
...