Linux常用命令-ethtool

命令

ethtool

描述

query or control network driver and hardware settings
配置网络设备

用法

1
ethtool DEVNAME

选项

1
2
3
Options:
-i,--driver 查询指定的网络设备以获取相关的驱动程序信息
-S,--statistics 查询指定网络设备的NIC和特定于驱动程序的统计信息

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
$ ethtool --version
ethtool version 4.8

# 显示网卡设备信息
$ ethtool eth0
Settings for eth0:
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

# 显示网卡流量
$ ethtool -S eth0 | head -14
NIC statistics:
rx_packets: 324949
tx_packets: 62301
rx_bytes: 55550113
tx_bytes: 6312990
rx_broadcast: 0
tx_broadcast: 0
rx_multicast: 0
tx_multicast: 0
rx_errors: 0
tx_errors: 0
tx_dropped: 0
multicast: 0
collisions: 0
# 和ifconfig显示的信息一致
$ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.31.11 netmask 255.255.255.0 broadcast 192.168.31.255
ether 00:50:56:29:9c:ed txqueuelen 1000 (Ethernet)
RX packets 326081 bytes 54321793 (51.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 62433 bytes 6328064 (6.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

# 显示网卡驱动
$ ethtool -i eth0
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:02:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no
$ ethtool -i eth0
driver: virtio_net
version: 1.0.0
firmware-version:
expansion-rom-version:
bus-info: 0000:00:05.0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no