ethtool

导览:

    1. 如何查看 Linux 中可用的网卡接口

    2. 如何查看 Linux 中网卡信息

    3. 如何查看网卡驱动版本以及硬件版本

    4. 如何查看网络使用情况统计

    5. 如何改变网卡速率

    6. 如何改变网卡自动协商

    7. 如何识别网卡



  ethtool 用于查看和修改网络设备(尤其是有线以太网设备)的驱动参数和硬件设置。你可以根据需要更改以太网卡的参数,包括自动协商、速度、双工和局域网唤醒等参数。通过对以太网卡的配置,你的计算机可以通过网络有效地进行通信。该工具提供了许多关于接驳到你的 Linux 系统的以太网设备的信息

首先了解下以太网卡的工作原理:

  • 半双工:半双工模式允许设备一次只能发送或接收数据包。
  • 全双工:全双工模式允许设备可以同时发送和接收数据包。
  • 自动协商:自动协商是一种机制,允许设备自动选择最佳网速和工作模式(全双工或半双工模式)。
  • 速度:默认情况下,它会使用最大速度,你可以根据自己的需要改变它。
  • 链接检测:链接检测可以显示网卡的状态。如果显示为 no,请尝试重启网卡。如果链路检测仍显示 no,则检查交换机与系统之间连接的线缆是否有问题。

1. 如何查看 Liunx 中可用的网卡接口

使用 ip a 或 ifconfig 来查看网卡

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:e8:e7:7d brd ff:ff:ff:ff:ff:ff
inet 192.168.3.10/24 brd 192.168.3.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::1e3:3f1:c524:8f87/64 scope link noprefixroute
valid_lft forever preferred_lft forever

2. 如何查看 Linux 中网卡信息

在 Linux 系统中,每个网卡(NIC)都被分配了唯一的名称,如 ethX、enpXXX 等旧的 Linux 发行版使用的是 eth[X] 格式。例如,RHEL 6 和它们的旧版本。

现代的 Linux 发行版使用 enp[XXX]ens[XXX] 格式,例如,大多数现代 Linux 发行版都使用这种格式,包括 RHEL 7、Debian 10、Ubuntu 20.04 LTS

[root@localhost ~]# ethtool ens33
Settings for ens33:
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 # 支持的 FEC 模式
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 # 支持的 FEC 模式
Speed: 1000Mb/s # 当前速率
Duplex: Full # 工作模式全双工
Port: Twisted Pair # 端口:双绞线
PHYAD: 0
Transceiver: internal # 收发器:内部
Auto-negotiation: on # 自动协商:打开
MDI-X: off (auto) # MDI-X
Supports Wake-on: d # 支持唤醒
Wake-on: d # 唤醒
Current message level: 0x00000007 (7) # 当前消息级别
drv probe link # drv 链路探测
Link detected: yes # 检测到链接

3. 如何查看网卡驱动版本以及硬件版本

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

4. 如何查看网络使用情况统计

NIC statistics:
rx_packets: 1000 # 接收数据包
tx_packets: 370 # 发送数据包
rx_bytes: 105532 # 接收字节
tx_bytes: 53631 # 发送字节
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: 105532
rx_csum_offload_good: 854
rx_csum_offload_errors: 0
alloc_rx_buff_failed: 0
tx_smbus: 0
rx_smbus: 0
dropped_smbus: 0

5. 如何改变网卡速率

更改完之后需要重启网卡

[root@localhost ~]# ethtool -s ens33 speed 1000

6. 如何改变网卡自动协商

[root@localhost ~]# ethtool -s ens33 autoneg off/on

7. 如何识别网卡

[root@localhost ~]# ethtool -p ens33

使用过后,网卡灯会闪

ethtool - 命令的更多相关文章

  1. ethtool命令

    用途 显示或修改以太网卡的配置信息. 语法 ethtool [ -a | -c | -g | -i | -d | -k | -r | -S |] ethX ethtool [-A] ethX [aut ...

  2. 用ethtool 命令解决Linux 网卡丢包【转】

    转自:https://blog.csdn.net/chengxuyuanyonghu/article/details/73739516 生产中有一台Linux设备并发比较大,droped包比较多,尤其 ...

  3. Linux ethtool命令

    一.简介 ethtool 是用于查询及设置网卡参数的命令. 二.常用选项 ethtool ethx //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等 ethtool ...

  4. ethtool 命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等 转自: ...

  5. 【linux命令与工具】ethtool命令

    ethtool是用于查询及设置网卡参数的命令. 如果command not found可以用apt-get/yum添加. 主要参数: ethtool ethX//查看ethX设备属性 ethtool ...

  6. 【转】ethtool 命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等etht ...

  7. Linux ethtool 命令

    ethtool 是用于查询及设置网卡参数的命令,常见用法如下: 注意:该命令只是临时设置,如果网卡重启就失效了,如果想要永久保存应该配置 /etc/sysconfig/network-scripts/ ...

  8. ethtool命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等etht ...

  9. ethtool命令使用

    [root@localhost ~]# ethtool -s eth0 speed 100 duplex full #设置网口的speed和duplex # ethtool eth0Settings ...

随机推荐

  1. 海 鱼立 鲷 & 海䲞鲷

    海 鱼立 鲷 & 海䲞鲷 䲞 lì 鲷 diāo 二长棘鲷 二长棘鲷(学名:Parargyrops edita)为辐鳍鱼纲鲈形目鲷科二长棘鲷属的鱼类,俗名板鱼.䲞鱼.盘仔鱼.立花.赤鬃.长鳍. ...

  2. SVG 与 Canvas 对比

    SVG 与 Canvas 对比 技术选型 SVG vs Canvas 应用场景 性能 GPU 加速 XML 数据存储 Canvas 2D Canvas 3D WebGL / OpenGL ES thr ...

  3. Frameworkless Movement

    Frameworkless Movement 无框架运动 https://www.frameworklessmovement.org/ vanilla javascript https://githu ...

  4. React & Calendar

    React & Calendar 日历 https://github.com/YutHelloWorld/calendar/blob/master/src/Calendar.js // 国际化 ...

  5. Build your own React

    Build your own React https://pomb.us/build-your-own-react/ https://github.com/pomber/didact demo htt ...

  6. Google can't be accessed again, today is shit day

    Google can't be accessed again, today is shit day 2019.11.28 12:00~20:56 holy shit (pile of poop) Go ...

  7. HTML Imports & deprecated

    HTML Imports & deprecated https://caniuse.com/#search=html imports https://www.chromestatus.com/ ...

  8. clisp的一些function

    ;; example: (write (A-Z :start (+ 65 1) :end 87)) (defmacro A-Z (&key (start 65) (end 90)) (let* ...

  9. NGK创造的BGV金融世界观是什么?

    目前DeFi已经形成初级的金融体系.笔者将DeFi市场对比传统金融世界观,不过市场结构有显着差异.我们可以这样想:如果在去中心化金融世界中借钱,那么可以把MakerDAO比作为中央银行(+回购). 去 ...

  10. [转]ROS订阅激光数据

    https://github.com/robopeak/rplidar_ros/blob/master/src/client.cpp /*   * Copyright (c) 2014, RoboPe ...