【计算机网络】10、ethtool

在这里插入图片描述

文章目录

  • 一、ethtool
    • 1.1 常见操作
      • 1.1.1 展示设备属性
      • 1.1.2 改变网卡属性
        • 1.1.2.1 Auto-negotiation
        • 1.1.2.2 Speed
      • 1.1.3 展示网卡驱动设置
      • 1.1.4 只展示 Auto-negotiation, RX and TX
      • 1.1.5 展示统计
      • 1.1.7 排除网络故障
      • 1.1.8 通过网口的 LED 区分网卡
      • 1.1.9 持久化配置(无需 reboot)

一、ethtool

ethtool is used to query and control network device driver and hardware settings, particularly for wired Ethernet devices.

devname is the name of the network device on which ethtool should operate.

man 文档
参考

1.1 常见操作

1.1.1 展示设备属性

# root@ubuntu:~# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536# ethtool eno1
Settings for eno1:Supported ports: [ TP	 MII ]Supported link modes:   10baseT/Half 10baseT/Full100baseT/Half 100baseT/Full1000baseT/FullSupported pause frame use: Symmetric Receive-onlySupports auto-negotiation: YesSupported FEC modes: Not reportedAdvertised link modes:  10baseT/Half 10baseT/Full100baseT/Half 100baseT/Full1000baseT/FullAdvertised pause frame use: Symmetric Receive-onlyAdvertised auto-negotiation: YesAdvertised FEC modes: Not reportedSpeed: Unknown!Duplex: Unknown! (255)Auto-negotiation: onmaster-slave cfg: preferred slavemaster-slave status: unknownPort: Twisted PairPHYAD: 0Transceiver: externalMDI-X: UnknownSupports Wake-on: pumbgWake-on: dLink detected: no# ethtool docker0
Settings for docker0:Supported ports: [  ]Supported link modes:   Not reportedSupported pause frame use: NoSupports auto-negotiation: NoSupported FEC modes: Not reportedAdvertised link modes:  Not reportedAdvertised pause frame use: NoAdvertised auto-negotiation: NoAdvertised FEC modes: Not reportedSpeed: 10000Mb/sDuplex: Unknown! (255)Auto-negotiation: offPort: OtherPHYAD: 0Transceiver: internalLink detected: yes# ethtool lo
Settings for lo:Link detected: yes

其中全双工、半双工、自动协商的区别如下:

  • Full duplex : Enables sending and receiving of packets at the same time. This mode is used when the ethernet device is connected to a switch(交换机).
  • Half duplex : Enables either sending or receiving of packets at a single point of time. This mode is used when the ethernet device is connected to a hub(集线器).
  • Auto-negotiation : If enabled, the ethernet device itself decides whether to use either full duplex or half duplex based on the network the ethernet device attached to.

1.1.2 改变网卡属性

1.1.2.1 Auto-negotiation

上文展示的 Auto-negotiation 为 true,可通过 -s autoneg 关闭它。

# ifdown eth0eth0      device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)eth0      configuration: eth-bus-pci-0000:0b:00.0# ethtool -s eth0 autoneg off # -s 指定网卡名称, 设置 autoneg = off# ethtool eno1
Settings for eno1:Supported ports: [ TP	 MII ]Supported link modes:   10baseT/Half 10baseT/Full100baseT/Half 100baseT/Full1000baseT/Full。。。Auto-negotiation: off # 此处信息已变为 offLink detected: down # 此处信息已变为 down# ifup eno1

1.1.2.2 Speed

改变网卡速度,注意不要设置超过网卡的 limited capacity

# ethtool eth0 | grep SpeedSpeed: 1000Mb/s# ethtool -s eth0 speed 100 autoneg off# ethtool eth0 | grep SpeedSpeed: Unknown! (65535) # 注意:如果网卡在 online 时,被改了 speed 则会自动变为 offline,此时需要手动 ifup# ifup eth0eth0      device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)eth0      configuration: eth-bus-pci-0000:0b:00.0Checking for network time protocol daemon (NTPD):                     running# ethtool eth0 | grep SpeedSpeed: 100Mb/s# 可看到设置后从 1000Mb/s 变为 100Mb/s

可通过 ifconfig 设置 MTU

1.1.3 展示网卡驱动设置

# ethtool  -i eno1
driver: r8169
version: 5.19.1-051901-generic
firmware-version: rtl8168h-2_0.0.2 02/26/15
expansion-rom-version:
bus-info: 0000:59:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

1.1.4 只展示 Auto-negotiation, RX and TX

# ethtool -a eno1
Pause parameters for eno1:
Autonegotiate:	on
RX:		off
TX:		off# 参数含义如下:
-a --show-pauseQueries the specified Ethernet device for pause parameter information.

1.1.5 展示统计

# ethtool -S eno1
NIC statistics:tx_packets: 6199rx_packets: 16548tx_errors: 0rx_errors: 1rx_missed: 0align_errors: 0tx_single_collisions: 0tx_multi_collisions: 0unicast: 4228broadcast: 10859multicast: 1461tx_aborted: 0tx_underrun: 0

1.1.7 排除网络故障

连接成功后,我们期望 Speed 是明确的值,Duplex 是 Full/Half,Link detection 是 Yes。如果不是(如Speed、Duplex 为 Unknow 时,Link detection 为 No 时),可能交换机或网络设置有问题。

此时可以用 tcpdump 抓包分析。

1.1.8 通过网口的 LED 区分网卡

如果机器有很多网口,设置后,对应的网口即会亮灯,即可区分对应关系

ethtool -p eth0# 参数含义如下:-p --identifyInitiates adapter-specific action intended to enable an operator to easily identify the adapter by sight.  Typically this involves blinking one or more LEDs on the specific network port.启动特定于适配器的操作,以使操作员能够轻松地通过视觉识别适配器。这通常涉及闪烁特定网络端口上的一个或多个LED。[N]   Length of time to perform phys-id, in seconds.

1.1.9 持久化配置(无需 reboot)

通过 ethtool 设置后,reboot 仍会恢复为设置前的状态。但可通过写配置文件的方式来持久化。

  • ubuntu 设置如下:在 /etc/network/interfaces 配置则会持久化。
# vim /etc/network/interfaces
post-up ethtool -s eno1 speed 1000 duplex full autoneg off # 此行应为本文件的最后一行
  • SUSE 设置如下:
    modify the /etc/sysconfig/network/ifcfg-eth-id file and include a new script using POST_UP_SCRIPT variable as shown below. Include the below line as the last line in the corresponding eth1 adpater config file.
# vim /etc/sysconfig/network/ifcfg-eth-id
POST_UP_SCRIPT='eth1'

Then, create a new file scripts/eth1 as shown below under /etc/sysconfig/network directory. Make sure that the script has execute permission and ensure that the ethtool utility is present under /sbin directory.

# cd /etc/sysconfig/network/# vim scripts/eth1
#!/bin/bash
/sbin/ethtool -s duplex full speed 100 autoneg off

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/14269.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

QT--day5(网络聊天室、学生信息管理系统)

服务器&#xff1a; #include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this);//给服务器指针实例化空间servernew QTcpServer(this); }Widget::~Widget() {delete ui; …

Codeforces Round 889 (Div. 2)题解

目录 A. Dalton the Teacher题目大意题解思路代码 B. Longest Divisors Interval题目大意题解思路代码 C1. Dual (Easy Version)题目大意题解思路代码 A. Dalton the Teacher 题目链接 题目大意 Dalton是一个班级的老师&#xff0c;这个班级有 n n n个学生&#xff0c;分别…

GDAL C++ API 学习之路 OGRGeometry 抽象曲线基类 OGRCurve

OGRCurve class "ogrsf_frmts.h" OGRCurve 是 OGR&#xff08;OpenGIS Simple Features Reference Implementation&#xff09;几何库中的一个基类&#xff0c;表示曲线几何对象。它是 OGRLineString 和 OGRCircularString 的抽象基类&#xff0c;用于表示曲…

Kotlin知识点

Kotlin 是 Google 推荐的用于创建新 Android 应用的语言。使用 Kotlin&#xff0c;可以花更短的时间编写出更好的 Android 应用。 基础 Kotlin 程序必须具有主函数&#xff0c;这是 Kotlin 编译器在代码中开始编译的特定位置。主函数是程序的入口点&#xff0c;或者说是起点。…

JavaScript 作用域与闭包

本文内容学习于&#xff1a;后盾人 (houdunren.com) 1.作用域 1)函数被执行后其环境变量将从内存中删除。下面函数在每次执行后将删除函数内部的 total 变量。 function count() { let total 0; } count (); 2)函数每次调用都会创建一个新作用域 3)如果子函数被使用时父级环境…

【C++】类和对象 - 上

目录 1. 面向过程和面向对象初步认识2. 类的引入3. 类的定义4. 类的访问限定符及封装4.1 访问限定符4.2 封装 5. 类的作用域6. 类的实例化7. 类对象模型7.1 如何计算类的大小7.2 类对象的存储方式猜测7.3 结构体内存对齐规则 8. this指针8.1 引出8.2 this指针的特性 总结 1. 面…

【Leetcode】53. 最大子数组和

一、题目 1、题目描述 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例1: 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大,为 6 。…

打卡力扣题目四

#左耳听风 ARST 打卡活动重启# 目录 一、题目 二、解题代码 三、解题思路 关于 ARTS 的释义 —— 每周完成一个 ARTS&#xff1a; ● Algorithm: 每周至少做一个 LeetCode 的算法题 ● Review: 阅读并点评至少一篇英文技术文章 ● Tips: 学习至少一个技术技巧 ● Share: 分享…

列表list

列表 列表是将数据组织在一个一维集合中&#xff0c;从这个组织方式来看&#xff0c;它与c()函数是相似的。但是&#xff0c;列表并不是将具体的值组织起来&#xff0c;而是组织R对象&#xff0c;如列表、数据框、矩阵、函数、向量等等。 列表非常好用&#xff0c;因为列表可…

打开域名跳转其他网站,官网被黑解决方案(Linux)

某天打开网站&#xff0c;发现进入首页&#xff0c;马上挑战到其他赌博网站。 事不宜迟&#xff0c;不能让客户发现&#xff0c;得马上解决 我的网站跳转到这个域名了 例如网站跳转到 k77.cc 就在你们部署的代码的当前文件夹下面&#xff0c;执行下如下命令 find -type …

Electron 系统通知 Notification 实践指南

系统通知是桌面应用的常见功能&#xff0c;用于给用户发送提醒&#xff08;刷下存在感 &#x1f642;&#xff09;&#xff0c;还能帮定点击事件以便后续的操作。 Electron 自带通知模块&#xff0c;下方代码是一个简单的示例 const { Notification } require(electron)cons…

电脑维护指南:让你的战友始终高效稳定

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…

【Ansible】

目录 一、Ansible简介二、ansible 环境安装部署1、管理端安装 ansible 三、ansible 命令行模块&#xff08;重点&#xff09;1&#xff0e;command 模块2&#xff0e;shell 模块3、cron 模块4&#xff0e;user 模块5&#xff0e;group 模块6&#xff0e;copy 模块&#xff08;重…

【论文精读】Self-Attentive Assocative Memory,2020

目录 1 引言2 Outer product attention (OPA)3 Self-attentive Associative Memory (SAM)4 SAM-based Two-Memory Model (STM)4.1 M i M^i Mi写操作4.2 M r M^r Mr读操作4.3 M i M^i Mi读操作和 M r M^r Mr写操作过程4.4 用 M r M^r Mr实现item转移4.5 模型输出 o t o_t ot​…

c语言内存函数的深度解析

本章对 memcpy&#xff0c;memmove&#xff0c;memcmp 三个函数进行详解和模拟实现&#xff1b; 本章重点&#xff1a;3个常见内存函数的使用方法及注意事项并学会模拟实现&#xff1b; 如果您觉得文章不错&#xff0c;期待你的一键三连哦&#xff0c;你的鼓励是我创作的动力…

el-table数据处理

在写表格时遇到&#xff0c;后端返回的数据是对象&#xff0c;并且缺少字段 1.每一条数据加上 一个字段 2.将对象转成数组 以下是数据 {"groupA": {"groupName": null,"orgName": null,"orgId": null,"allPeoper": &quo…

C# 泛型(Generic)

方法重载&#xff1a;方法名称相同&#xff0c;参数个数和参数类型不同&#xff1b; 优势&#xff1a;可以节约方法名称 劣势&#xff1a;方法过多 语法&#xff1a;public void writeContent(T t) 原理&#xff1a;普通的C#代码他是运行在前端进行编译&#xff0c;所有的类型需…

IntersectionObserver实现小程序长列表优化

IntersectionObserver实现小程序长列表优化 关于 IntersectionObserver 思路 这里以一屏数据为单位【一个分页的10条数据&#xff0c;最好大于视口高度】&#xff0c; 监听每一屏数据和视口的相交比例&#xff0c;即用户能不能看到它 只将可视范围的数据渲染到页面上&#x…

[Spring]Spring声明式事务总结

文章目录 1、介绍2、Spring事务的隔离级别3、事务的传播行为4、Transactional注解包含的属性5、使用6、Transactional失效场景 1、介绍 声明式事务管理是建立在 AOP 之上的。其本质是通过 AOP 功能&#xff0c;对方法前后进行拦截&#xff0c;将事务处理的功能编织到拦截的方法…

Oracle 19c 报ORA-704 ORA-01555故障处理---惜分飞

异常断电导致数据库无法启动,尝试对数据文件进行recover操作,报ORA-00283 ORA-00742 ORA-00312错误,由于redo写丢失无法正常应用 D:\check_db>sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on 星期日 7月 30 07:49:19 2023 Version 19.3.0.0.0 Copyrig…