linux覆盖文件如何还原_如何使用ethtool命令操作以太网卡

894b49bbfb49a6348f14ff11d13bec54.png

https://www.itq168.com/minibooks/125

ethtool用于查看和修改网络设备驱动程序参数和硬件设置,尤其是对于有线以太网设备。

您可以根据需要更改以太网卡参数,包括自动协商,速度,双工和唤醒LAN。

以太网卡的配置使您的计算机可以有效地通过网络进行通信。

该工具提供了许多有关连接到Linux系统的以太网设备的信息。

在本文中,我们将向您展示如何更改以下参数以及如何查看它们。

本文将帮助您解决Linux系统上与以太网卡相关的问题。

以下信息将帮助您了解以太网卡的工作方式。

•半双工:半双工模式允许设备一次发送或接收数据包。•全双工:全双工模式允许设备同时发送和接收数据包。•自动协商:自动协商是一种机制,允许设备自动选择最佳的网络速度和操作模式(全双工或半双工模式)。•速度:默认情况下,它使用最大速度,您可以根据需要进行更改。•链接检测:链接检测显示网络接口卡的状态。如果显示“否”,请尝试重新启动界面。如果链路检测仍然显示“否”,请检查交换机和系统之间连接的电缆是否有问题。

如何在Linux上安装ethtool

默认情况下,ethtool应该已经安装在大多数系统上。如果没有,您可以从发行官方库中安装它。

对于RHEL / CentOS 6/7系统,请使用 yum命令 安装ethtool。

$ sudo yum install -y ethtool
对于RHEL / CentOS 6/7系统,请使用 yum命令 安装ethtool。
$ sudo yum install -y ethtool
对于基于Debian的系统,请使用 apt命令 或 apt-get命令 安装ethtool。
$ sudo apt-get install ethtool
对于openSUSE系统,请使用 zypper命令 安装ethtool。
$ sudo zypper install -y ethtool
对于Arch Linux系统,请使用 pacman命令 安装ethtool。
$ sudo pacman -S ethtool
如何在Linux上检查可用的网络接口

可以使用ip命令或ifconfig命令(在现代发行版中已弃用)来验证可用和活动网络接口的名称和其他详细信息。

# ip aor# ifconfig1: lo: 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 forever2: eth0: mtu 1500 qdisc mq state UP group default qlen 1000    link/ether 00:10:22:35:23:sf brd ff:ff:ff:ff:ff:ff    inet 192.164.23.100/24 brd 192.164.23.255 scope global eth0       valid_lft forever preferred_lft forever

如何在Linux上检查网络接口卡(NIC)信息

有了以太网接口名称后,您可以使用ethtool命令轻松检查其详细信息,如下所示。

在Linux上,为每个网络接口卡(NIC)分配了唯一的名称,例如ethX,enpXXX等。

较早的Linux发行版使用eth [X]格式。例如,RHEL 6及其早期版本。

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

# ethtool eth0Settings for eth0:        Supported ports: [ TP ]        Supported link modes: 1000baseT/Full                              10000baseT/Full        Supported pause frame use: No        Supports auto-negotiation: No        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: 10000Mb/s        Duplex: Full        Port: Twisted Pair        PHYAD: 0        Transceiver: internal        Auto-negotiation: off        MDI-X: Unknown        Supports Wake-on: uag        Wake-on: d        Link detected: yes
如何在Linux上检查以太网卡驱动程序和固件版本

您可以使用带有“ -i”选项的ethtool命令来检查驱动程序版本,固件版本和总线详细信息,如下所示。

# ethtool -i eth0driver: vmxnet3version: 1.4.16.0-k-NAPIfirmware-version:expansion-rom-version:bus-info: 0000:0b:00.0supports-statistics: yessupports-test: nosupports-eeprom-access: nosupports-register-dump: yessupports-priv-flags: no
如何在Linux上检查网络使用情况统计信息

您可以使用带有“ -S”选项的ethtool命令查看网络使用情况统计信息。它显示了传输,接收,错误等字节。

# ethtool -S eth0NIC statistics:     Tx Queue#: 0       TSO pkts tx: 2053       TSO bytes tx: 7167572       ucast pkts tx: 4028081       ucast bytes tx: 399093197       mcast pkts tx: 0       mcast bytes tx: 0       bcast pkts tx: 0       bcast bytes tx: 0       pkts tx err: 0       pkts tx discard: 0       drv dropped tx total: 0          too many frags: 0          giant hdr: 0          hdr err: 0          tso: 0       ring full: 0       pkts linearized: 0       hdr cloned: 0       giant hdr: 0     Tx Queue#: 1       TSO pkts tx: 1955       TSO bytes tx: 6536945       ucast pkts tx: 3711838       ucast bytes tx: 346309662       mcast pkts tx: 0       mcast bytes tx: 0       bcast pkts tx: 1186       bcast bytes tx: 49812       pkts tx err: 0       pkts tx discard: 0       drv dropped tx total: 0          too many frags: 0          giant hdr: 0          hdr err: 0          tso: 0       ring full: 0       pkts linearized: 0       hdr cloned: 0       giant hdr: 0     Rx Queue#: 0       LRO pkts rx: 0       LRO byte rx: 0       ucast pkts rx: 5084776       ucast bytes rx: 4673133395       mcast pkts rx: 0       mcast bytes rx: 0       bcast pkts rx: 154143       bcast bytes rx: 45415676       pkts rx OOB: 0       pkts rx err: 0       drv dropped rx total: 0          err: 0          fcs: 0       rx buf alloc fail: 0     Rx Queue#: 1       LRO pkts rx: 0       LRO byte rx: 0       ucast pkts rx: 6346769       ucast bytes rx: 4835534292       mcast pkts rx: 0       mcast bytes rx: 0       bcast pkts rx: 3464       bcast bytes rx: 714646       pkts rx OOB: 0       pkts rx err: 0       drv dropped rx total: 0          err: 0          fcs: 0       rx buf alloc fail: 0     tx timeout count: 0
如何在Linux上更改以太网设备的速度

您可以根据需要更改以太网的速度。进行此更改后,该接口将自动脱机,并且您需要使用ifup命令或ip命令或nmcli命令使其重新联机。

# ethtool -s eth0 speed 100# ip link set eth0 up
如何在Linux上启用/禁用以太网设备的自动协商

您可以使用带有“ autoneg”选项的ethtool命令启用或禁用自动协商,如下所示。

# ethtool -s eth0 autoneg off# ethtool -s eth0 autoneg on

如何一次更改多个参数

如果要使用ethtool命令同时更改以太网接口的多个参数,请使用以下格式。

Syntax:ethtool –s [device_name] speed [10/100/1000] duplex [half/full] autoneg [on/off]# ethtool –s eth0 speed 1000 duplex full autoneg off

如何在Linux上检查特定接口的自动协商,RX和TX

要查看有关特定以太网设备的自动协商详细信息,请使用以下格式。

# ethtool -a eth0
如何从多个设备识别特定的NIC(NIC卡的闪烁LED端口)

如果要识别其他特定的物理接口端口,此选项非常有用。下面的ethtool命令使eth0端口的LED闪烁。

# ethtool -p eth0
如何在Linux中永久设置这些参数

系统重新启动后,默认情况下将还原使用ethtool所做的更改。

要使自定义设置永久生效,您需要更新网络配置文件中的值。根据您的Linux发行版,您可能需要将此值更新为正确的文件。

对于基于RHEL的系统。您必须使用ETHTOOL_OPTS变量。

# vi /etc/sysconfig/network-scripts/ifcfg-eth0ETHTOOL_OPTS="speed 1000 duplex full autoneg off"

对于基于Debian的系统。

# vi /etc/network/interfacespost-up ethtool -s eth0 speed 1000 duplex full autoneg off

翻译来源:

https://www.2daygeek.com/linux-ethtool-command-view-change-ethernet-adapter-settings-nic-card/

ea30f7f88d9633c20bb6bd03b030e150.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值