1 概述
 
ethtool 是用于查询及设置网卡参数的命令。
 
2 命令详解
 
2.1 命令格式

(1) 语法

ethtool [ -a | -c | -g | -i | -d | -k | -r | -S |] ethX
     
    ethtool [-A] ethX [autoneg on|off] [rx on|off] [tx on|off]
     
    ethtool [-C] ethX [adaptive-rx on|off] [adaptive-tx on|off] [rx-usecs N]
                 [rx-frames N] [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N]
                 [tx-frames N] [tx-usecs-irq N] [tx-frames-irq N] [stats-block-usecs N]
                 [pkt-rate-low N][rx-usecs-low N] [rx-frames-low N] [tx-usecs-low N]
                 [tx-frames-low N] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N]
                 [tx-usecs-high N] [tx-frames-high N] [sample-interval N]
     
    ethtool [-G] ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]
     
    ethtool [-e] ethX [raw on|off] [offset N] [length N]
     
    ethtool [-E] ethX [magic N] [offset N] [value N]
     
    ethtool [-K] ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off]
     
    ethtool [-p] ethX [N]
     
    ethtool [-t] ethX [offline|online]
     
    ethtool [-s] ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off]
                 [port tp|aui|bnc|mii] [phyad N] [xcvr internal|external]
     
    [wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

(2) 描述

ethX是以太网卡的名称,Linux系统将检测到的第一块以太网卡命名为eth0, 第二块为eth1,…….。
 
2.2 命令常见参数说明

参数
   
说明

-a
查看网卡中接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。

-A
 修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-c
display the Coalesce(聚合、联合) information of the specified ethernet card.聚合网口信息,使看起来更有规律。
-C
  Change the Coalesce setting of the specified ethernet card.修改网卡聚合信息。
-g
Display the rx/tx ring parameter information of the specified ethernet card. 显示网卡的接收/发送环形参数。
-G
  Change the rx/tx ring setting of the specified ethernet card. 修改网卡的接收/发送环形参数。
-i
  显示网卡驱动的信息,如驱动的名称、版本等。
-d
显示register dump信息, 部分网卡驱动不支持该选项。
-e
显示EEPROM dump信息,部分网卡驱动不支持该选项。
-E
修改网卡EEPROM byte.
-k
显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。
-K
修改网卡Offload参数的状态
-p
用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。
-r
如果auto-negotiation模块的状态为on,则restarts auto-negotiation.
-s
修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等。加上-s选项修改的内容才会生效
-S
显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t
 让网卡执行自我检测,有两种模式:offline or online.
 
2.3 输出详解
     [root@localhost ~]# 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 // 当前速率 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

3 简单实例

3.1 查询网口基本设置
 (1)命令

ethtool ethx

(2) 功能

查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等。

(3) 实例

[root@localhost ~]# 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
    [root@localhost ~]#

3.2 查询网口的驱动相关信息

(1) 命令

ethtool -i ethx

(2) 功能

查询网口的驱动相关信息,如驱动名称、版本信息等。

(3) 实例

[root@localhost ~]# ethtool -i eth0
    driver: e1000
    version: 7.3.21-k8-NAPI
    firmware-version:
    expansion-rom-version:
    bus-info: 0000:02:01.0
    supports-statistics: yes
    supports-test: yes
    supports-eeprom-access: yes
    supports-register-dump: yes
    supports-priv-flags: no
 
3.3 查询ethx网口注册性信息

(1) 命令

ethtool -d ethx

(2) 功能

查询网口注册性信息。

(3) 实例

[root@localhost ~]# ethtool -d eth0
    MAC Registers
    -------------
    0x00000: CTRL (Device control register) 0x00C00249
    Endian mode (buffers): little
    Link reset: reset
    Set link up: 1
    Invert Loss-Of-Signal: no
    Receive flow control: disabled
    Transmit flow control: disabled
    VLAN mode: disabled
    Auto speed detect: disabled
    Speed select: 1000Mb/s
    Force speed: no
    Force duplex: no
    0x00008: STATUS (Device status register) 0x0000CB83
    Duplex: full
    Link up: link config
    TBI mode: disabled
    Link speed: 1000Mb/s
    Bus type: PCI
    Bus speed: 66MHz
    Bus width: 32-bit
    0x00100: RCTL (Receive control register) 0x00008002
    Receiver: enabled
    Store bad packets: disabled
    Unicast promiscuous: disabled
    Multicast promiscuous: disabled
    Long packet: disabled
    Descriptor minimum threshold size: 1/2
    Broadcast accept mode: accept
    VLAN filter: disabled
    Canonical form indicator: disabled
    Discard pause frames: filtered
    Pass MAC control frames: do not pass
    Receive buffer size: 2048
    0x02808: RDLEN (Receive desc length) 0x00001000
    0x02810: RDH (Receive desc head) 0x00000035
    0x02818: RDT (Receive desc tail) 0x00000033
    0x02820: RDTR (Receive delay timer) 0x00000000
    0x00400: TCTL (Transmit ctrl register) 0x0103F0FA
    Transmitter: enabled
    Pad short packets: enabled
    Software XOFF Transmission: disabled
    Re-transmit on late collision: enabled
    0x03808: TDLEN (Transmit desc length) 0x00001000
    0x03810: TDH (Transmit desc head) 0x00000000
    0x03818: TDT (Transmit desc tail) 0x00000000
    0x03820: TIDV (Transmit delay timer) 0x00000008
    PHY type: M88
    M88 PHY STATUS REGISTER: 0x0000AC00
    Jabber: no
    Polarity: normal
    Downshifted: no
    MDI/MDIX: MDI
    Cable Length Estimate: 0-50 meters
    Link State: Up
    Speed & Duplex Resolved: Yes
    Page Received: No
    Duplex: Full
    Speed: 1000 mbps
    M88 PHY CONTROL REGISTER: 0x00000B68
    Jabber function: enabled
    Auto-polarity: disabled
    SQE Test: disabled
    CLK125: enabled
    Auto-MDIX: auto
    Extended 10Base-T Distance: disabled
    100Base-TX Interface: 5-bit
    Scrambler: disabled
    Force Link Good: disabled
    Assert CRS on Transmit: enabled

3.4 查询网口收发包统计

(1) 命令

ethtool -S ethx

(2) 功能

查询网口收发包统计。

(3) 实例

[root@localhost ~]# ethtool -S eth0
    NIC statistics:
    rx_packets: 447
    tx_packets: 17
    rx_bytes: 37053
    tx_bytes: 1268
    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
    rx_length_errors: 0
    rx_over_errors: 0
    rx_crc_errors: 0
    rx_frame_errors: 0
    rx_no_buffer_count: 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_abort_late_coll: 0
    tx_deferred_ok: 0
    tx_single_coll_ok: 0
    tx_multi_coll_ok: 0
    tx_timeout_count: 0
    tx_restart_queue: 0
    rx_long_length_errors: 0
    rx_short_length_errors: 0
    rx_align_errors: 0
    tx_tcp_seg_good: 0
    tx_tcp_seg_failed: 0
    rx_flow_control_xon: 0
    rx_flow_control_xoff: 0
    tx_flow_control_xon: 0
    tx_flow_control_xoff: 0
    rx_long_byte_count: 37053
    rx_csum_offload_good: 67
    rx_csum_offload_errors: 0
    alloc_rx_buff_failed: 0
    tx_smbus: 0
    rx_smbus: 0
    dropped_smbus: 0

3.5 设置网口工作方式

(1) 命令

ethtool -s ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off]

(2) 功能

设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商。自动协商关闭后,重新打开即可恢复原来的选项。

(3) 实例

[root@localhost ~]# ethtool -s eth0 autoneg off speed 100 duplex full
    [root@localhost ~]#
    [root@localhost ~]#
    [root@localhost ~]# 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: Not reported
    Advertised pause frame use: No
    Advertised auto-negotiation: No
    Advertised FEC modes: Not reported
    Speed: 100Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: off
    MDI-X: off (auto)
    Supports Wake-on: d
    Wake-on: d
    Current message level: 0x00000007 (7)
    drv probe link
    Link detected: yes
    [root@localhost ~]#
    [root@localhost ~]#
    [root@localhost ~]# ethtool -s eth0 autoneg on
    [root@localhost ~]#
    [root@localhost ~]#
    [root@localhost ~]# 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
    [root@localhost ~]#

3.6 指定通过自动协商机制通告的速度和双工方式

(1) 命令

ethtool -s ethX advertise N

(2) 功能

指定通过自动协商机制通告的速度和双工方式。N为十六进制值,如0x008表示100Mb/s+全双工、0x020表示1000Mb/s+全双工。

(3) 实例

[root@localhost ~]# ethtool -s eth0 advertise 0x008
    [root@localhost ~]#
    [root@localhost ~]# 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: 100baseT/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
 
3.7 其它

(1) 停止网卡的发送模块TX,请输入:

ethtool -A tx off eth0

操作完毕后,可输入:ethtool -a eth0,查看tx模块是否已被停止。

(2) 关闭网卡对收到的数据包的校验功能,请输入:

ethtool -K eth0 rx off

操作完毕后,可输入:ethtool -k eth0,查看校验功能是否已被停止。

(3) 如果机器上安装了两块网卡,那么eth0对应着哪块网卡呢?输入:

ethtool -p eth0 10

操作完毕后,看哪块网卡的led灯在闪,eth0就对应着哪块网卡。

(4) 查看网卡,在接收/发送数据时,有没有出错?请输入:

ethtool -S eth0

(5) 将千兆网卡的速度降为百兆,请输入:

ethtool -s eth0 speed 100

4 永久保存配置

将 ethtool 设置永久保存在网络设备有两种方法,一种是写入网口配置文件中,一种是开机自启动脚本。

(1) ethtool 设置可通过 /etc/sysconfig/network-scripts/ifcfg-ethx 文件保存,从而在设备下次启动时激活选项。

例如:ethtool -s eth0 speed 100 duplex full autoneg off

此指令将eth1设备设置为全双工自适应,速度为100Mbs。若要eth0启动时设置这些参数, 修改文件/etc/sysconfig/network-scripts/ifcfg-eth1 ,添加如下一行:

ETHTOOL_OPTS="speed 100 duplex full autoneg off"

(2) 将ethtool设置写入/etc/rc.d/rc.local之中,开机自动执行命令设置。

ethtool -s eth0 speed 100 duplex full autoneg off

---------------------
作者:路痴的旅行
来源:CSDN
原文:https://blog.csdn.net/u011857683/article/details/83758689
版权声明:本文为博主原创文章,转载请附上博文链接!

ethtools命令详解的更多相关文章

  1. Git初探--笔记整理和Git命令详解

    几个重要的概念 首先先明确几个概念: WorkPlace : 工作区 Index: 暂存区 Repository: 本地仓库/版本库 Remote: 远程仓库 当在Remote(如Github)上面c ...

  2. linux yum命令详解

    yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器自动下载RP ...

  3. Linux下ps命令详解 Linux下ps命令的详细使用方法

    http://www.jb51.net/LINUXjishu/56578.html Linux下的ps命令比较常用 Linux下ps命令详解Linux上进程有5种状态:1. 运行(正在运行或在运行队列 ...

  4. Docker命令详解

    Docker命令详解   最近学习Docker,将docker所有命令实验了一番,特整理如下: # docker --help Usage: docker [OPTIONS] COMMAND [arg ...

  5. linux awk命令详解

    linux awk命令详解 简介 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分 ...

  6. android adb 命令详解

    ADB (Android Debug Bridge)  是android SDK中的工具,需要先配置环境变量才能使用.起调试桥的作用,可以管理安卓设备.(也叫debug工具) ---------查看设 ...

  7. Git 常用命令详解

    Git 是一个很强大的分布式版本管理工具,它不但适用于管理大型开源软件的源代码(如:linux kernel),管理私人的文档和源代码也有很多优势(如:wsi-lgame-pro) Git 的更多介绍 ...

  8. Top 命令详解

    Top 命令详解 先感受一下top命令的执行结果吧!哈哈-- top - 17:32:34 up 3 days, 8:04, 5 users, load average: 0.09, 0.12, 0. ...

  9. Ruby Gem命令详解

    转自:http://www.jianshu.com/p/728184da1699 Gem介绍: Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.o ...

随机推荐

  1. Fiddler 断点功能

    Fiddler 断点: (1) Fiddler 是以作为代理服务器的方式进行工作的,所以,本地应用与服务器传递的这些数据都会经过 Fiddler:(2) 有的时候,我们希望在传递的中间进行修改后再传递 ...

  2. Web浏览器里的那些事

    初衷: 大脑中一直存在误区:一个Web前端工作者只要完美实现产品所提需求,至于浏览器究竟是怎么工作或者其中间都经历了些什么事情,就不用刨根问底了.直到最近看见前端大神winter老师关于浏览器部分的系 ...

  3. 使用npm安装webpack失败时,可能被墙要为cmd命令行设置代理

    一.搜索到的相关概念: Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. npm是 Node packaged Modules(node的包管理工具).本身用n ...

  4. socket.io 中文文档

    Socket.io是一个WebSocket库,包括了客户端的js和服务器端的nodejs,它的目标是构建可以在不同浏览器和移动设备上使用的实时应用.它会自动根据浏览器从WebSocket.AJAX长轮 ...

  5. windows Apache服务器简单配置虚拟域名(转载)

    1.找到apache目录下的conf下的extra下的httpd-vhosts.conf虚拟主机配置文件 将下面的代码复制粘贴到最下面:   #<VirtualHost *:80>#   ...

  6. Hadoop 跨集群访问

    [原文地址] 跨集群访问 发表于 2015-06-01   |   简单总结下跨集群访问的多种方式. 跨集群访问HDFS 直接给出HDFS URI 我们平常执行hadoop fs -ls /之类的操作 ...

  7. 使用 ASP.NET SignalR实现实时通讯

    ASP.NET SignalR 是为 ASP.NET 开发人员提供的一个库,可以简化开发人员将实时 Web 功能添加到应用程序的过程.实时 Web 功能是指这样一种功能:当所连接的客户端变得可用时服务 ...

  8. swust oj 962

    括号匹配问题 1000(ms) 65535(kb) 3045 / 13375 假设表达式中允许包含两种括号:圆括号和方括号.编写一个算法判断表达式中的括号是否正确配对. 输入 由括号构成的字符串,包含 ...

  9. ajax方式提交表单数据并判断当前注册用户是否存在

    项目的目录结构 源代码: regservlet.java package register; import java.io.IOException; import java.io.PrintWrite ...

  10. yum安装openjdk

    含有的命令:yum,java -version,javac,source,vim [root@ycj ~]# yum -y install java-1.8.0-openjdk-devel //安装j ...