自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何使用ethtool命令管理以太網(wǎng)卡

系統(tǒng) Linux
在這篇文章中,我們將告訴你如何更改以下的參數(shù)以及如何查看這些參數(shù)。這篇文章將幫助你在 Linux 系統(tǒng)中排除與以太網(wǎng)卡相關(guān)的問題。

[[329379]]

ethtool 用于查看和修改網(wǎng)絡設(shè)備(尤其是有線以太網(wǎng)設(shè)備)的驅(qū)動參數(shù)和硬件設(shè)置。你可以根據(jù)需要更改以太網(wǎng)卡的參數(shù),包括自動協(xié)商、速度、雙工和局域網(wǎng)喚醒等參數(shù)。通過對以太網(wǎng)卡的配置,你的計算機可以通過網(wǎng)絡有效地進行通信。該工具提供了許多關(guān)于接駁到你的 Linux 系統(tǒng)的以太網(wǎng)設(shè)備的信息。

在這篇文章中,我們將告訴你如何更改以下的參數(shù)以及如何查看這些參數(shù)。這篇文章將幫助你在 Linux 系統(tǒng)中排除與以太網(wǎng)卡相關(guān)的問題。

下面的信息將幫助你了解以太網(wǎng)卡的工作原理。

  • 半雙工:半雙工模式允許設(shè)備一次只能發(fā)送或接收數(shù)據(jù)包。
  • 全雙工:全雙工模式允許設(shè)備可以同時發(fā)送和接收數(shù)據(jù)包。
  • 自動協(xié)商:自動協(xié)商是一種機制,允許設(shè)備自動選擇最佳網(wǎng)速和工作模式(全雙工或半雙工模式)。
  • 速度:默認情況下,它會使用最大速度,你可以根據(jù)自己的需要改變它。
  • 鏈接檢測:鏈接檢測可以顯示網(wǎng)卡的狀態(tài)。如果顯示為 no,請嘗試重啟網(wǎng)卡。如果鏈路檢測仍顯示 no,則檢查交換機與系統(tǒng)之間連接的線纜是否有問題。

如何在 Linux 上安裝 ethtool

默認情況下,大多數(shù)系統(tǒng)上應該已經(jīng)安裝了 ethtool。如果沒有,你可以從發(fā)行版的官方版本庫中安裝。

對于 RHEL/CentOS 6/7 系統(tǒng),請使用 s-systems/" class="ext" rel="external nofollow" target="_blank">yum 命令 安裝 ethtool

  1. $ sudo yum install -y ethtool

對于 RHEL/CentOS 8 和 Fedora 系統(tǒng),請使用 dnf 命令 安裝 ethtool

  1. $ sudo yum install -y ethtool

對于基于 Debian 的系統(tǒng),請使用 apt 命令apt-get 命令 安裝 ethtool

  1. $ sudo apt-get install ethtool

對于 openSUSE 系統(tǒng),使用 zypper 命令 安裝 ethtool

  1. $ sudo zypper install -y ethtool

對于 Arch Linux 系統(tǒng),使用 pacman 命令 安裝 ethtool

  1. $ sudo pacman -S ethtool

如何檢查 Linux 上的可用網(wǎng)絡接口

你可以使用 ip 命令ifconfig 命令(在現(xiàn)代發(fā)行版中已被淘汰)來驗證可用的、活動的網(wǎng)卡的名稱和其他細節(jié):

  1. # ip a
  2. # ifconfig
  3.  
  4. 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
  5. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  6. inet 127.0.0.1/8 scope host lo
  7. valid_lft forever preferred_lft forever
  8. 2: eth0: mtu 1500 qdisc mq state UP group default qlen 1000
  9. link/ether 00:10:22:35:23:sf brd ff:ff:ff:ff:ff:ff
  10. inet 192.164.23.100/24 brd 192.164.23.255 scope global eth0
  11. valid_lft forever preferred_lft forever

如何檢查 Linux 上的網(wǎng)卡(NIC)信息

掌握了以太網(wǎng)卡名稱后,就可以使用 ethtool 命令輕松查看其詳細信息,如下所示。

在 Linux 系統(tǒng)中,每個網(wǎng)卡(NIC)都被分配了唯一的名稱,如 ethX、enpXXX 等。

  • 舊的 Linux 發(fā)行版使用的是 eth[X] 格式。例如,RHEL 6 和它們的舊版本。
  • 現(xiàn)代的 Linux 發(fā)行版使用 enp[XXX]ens[XXX] 格式。例如,大多數(shù)現(xiàn)代 Linux 發(fā)行版都使用這種格式,包括 RHEL 7、Debian 10、Ubuntu 16.04 LTS。
  1. # ethtool eth0
  2.  
  3. Settings for eth0:
  4. Supported ports: [ TP ]
  5. Supported link modes: 1000baseT/Full
  6. 10000baseT/Full
  7. Supported pause frame use: No
  8. Supports auto-negotiation: No
  9. Supported FEC modes: Not reported
  10. Advertised link modes: Not reported
  11. Advertised pause frame use: No
  12. Advertised auto-negotiation: No
  13. Advertised FEC modes: Not reported
  14. Speed: 10000Mb/s
  15. Duplex: Full
  16. Port: Twisted Pair
  17. PHYAD: 0
  18. Transceiver: internal
  19. Auto-negotiation: off
  20. MDI-X: Unknown
  21. Supports Wake-on: uag
  22. Wake-on: d
  23. Link detected: yes

如何檢查以太網(wǎng)卡的驅(qū)動程序和固件版本

你可以使用 ethtool 命令的 -i 選項檢查驅(qū)動程序版本、固件版本和總線的詳細信息,如下所示:

  1. # ethtool -i eth0
  2.  
  3. driver: vmxnet3
  4. version: 1.4.16.0-k-NAPI
  5. firmware-version:
  6. expansion-rom-version:
  7. bus-info: 0000:0b:00.0
  8. supports-statistics: yes
  9. supports-test: no
  10. supports-eeprom-access: no
  11. supports-register-dump: yes
  12. supports-priv-flags: no

如何檢查網(wǎng)絡使用情況統(tǒng)計

你可以使用 ethtool 命令中的 -S 選項來查看網(wǎng)絡使用情況統(tǒng)計。它可以顯示傳輸?shù)淖止?jié)數(shù)、接收的字節(jié)數(shù)、錯誤數(shù)等。

  1. # ethtool -S eth0
  2.  
  3. NIC statistics:
  4. Tx Queue#: 0
  5. TSO pkts tx: 2053
  6. TSO bytes tx: 7167572
  7. ucast pkts tx: 4028081
  8. ucast bytes tx: 399093197
  9. mcast pkts tx: 0
  10. mcast bytes tx: 0
  11. bcast pkts tx: 0
  12. bcast bytes tx: 0
  13. pkts tx err: 0
  14. pkts tx discard: 0
  15. drv dropped tx total: 0
  16. too many frags: 0
  17. giant hdr: 0
  18. hdr err: 0
  19. tso: 0
  20. ring full: 0
  21. pkts linearized: 0
  22. hdr cloned: 0
  23. giant hdr: 0
  24. Tx Queue#: 1
  25. TSO pkts tx: 1955
  26. TSO bytes tx: 6536945
  27. ucast pkts tx: 3711838
  28. ucast bytes tx: 346309662
  29. mcast pkts tx: 0
  30. mcast bytes tx: 0
  31. bcast pkts tx: 1186
  32. bcast bytes tx: 49812
  33. pkts tx err: 0
  34. pkts tx discard: 0
  35. drv dropped tx total: 0
  36. too many frags: 0
  37. giant hdr: 0
  38. hdr err: 0
  39. tso: 0
  40. ring full: 0
  41. pkts linearized: 0
  42. hdr cloned: 0
  43. giant hdr: 0
  44. Rx Queue#: 0
  45. LRO pkts rx: 0
  46. LRO byte rx: 0
  47. ucast pkts rx: 5084776
  48. ucast bytes rx: 4673133395
  49. mcast pkts rx: 0
  50. mcast bytes rx: 0
  51. bcast pkts rx: 154143
  52. bcast bytes rx: 45415676
  53. pkts rx OOB: 0
  54. pkts rx err: 0
  55. drv dropped rx total: 0
  56. err: 0
  57. fcs: 0
  58. rx buf alloc fail: 0
  59. Rx Queue#: 1
  60. LRO pkts rx: 0
  61. LRO byte rx: 0
  62. ucast pkts rx: 6346769
  63. ucast bytes rx: 4835534292
  64. mcast pkts rx: 0
  65. mcast bytes rx: 0
  66. bcast pkts rx: 3464
  67. bcast bytes rx: 714646
  68. pkts rx OOB: 0
  69. pkts rx err: 0
  70. drv dropped rx total: 0
  71. err: 0
  72. fcs: 0
  73. rx buf alloc fail: 0
  74. tx timeout count: 0

如何改變以太網(wǎng)設(shè)備的速度

你可以根據(jù)需要改變以太網(wǎng)的速度。當你進行此更改時,網(wǎng)卡將自動掉線,你需要使用 ifup 命令ip 命令或 nmcli 命令將其重新上。

  1. # ethtool -s eth0 speed 100
  2. # ip link set eth0 up

如何在 Linux 上啟用/禁用以太網(wǎng)卡的自動協(xié)商?

你可以使用 ethtool 命令中的 autoneg 選項啟用或禁用自動協(xié)商,如下圖所示:

  1. # ethtool -s eth0 autoneg off
  2. # ethtool -s eth0 autoneg on

如何同時更改多個參數(shù)

如果你想使用 ethtool 命令同時更改以太網(wǎng)卡的多個參數(shù),請使用下面的格式:

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

如何檢查特定網(wǎng)卡的自動協(xié)商、RX 和 TX

要查看關(guān)于特定以太網(wǎng)設(shè)備的自動協(xié)商等詳細信息,請使用以下格式:

  1. # ethtool -a eth0

如何從多個設(shè)備中識別出特定的網(wǎng)卡(閃爍網(wǎng)卡上的 LED)

如果你想識別一個特定的物理接口,這個選項非常有用。下面的 ethtool 命令會使 eth0 端口的 LED 燈閃爍:

  1. # ethtool -p eth0

如何在 Linux 中永久設(shè)置這些參數(shù)

在系統(tǒng)重啟后,你使用 ethtool 所做的更改將被默認恢復。

要使自定義設(shè)置永久化,你需要更新網(wǎng)絡配置文件中的值。根據(jù)你的 Linux 發(fā)行版,你可能需要將此值更新到正確的文件中。

對于基于 RHEL 的系統(tǒng)。你必須使用 ETHTOOL_OPTS 變量:

  1. # vi /etc/sysconfig/network-scripts/ifcfg-eth0
  2.  
  3. ETHTOOL_OPTS="speed 1000 duplex full autoneg off"

對于基于 Debian 的系統(tǒng):

  1. # vi /etc/network/interfaces
  2.  
  3. post-up ethtool -s eth0 speed 1000 duplex full autoneg off

 

責任編輯:龐桂玉 來源: Linux中國
相關(guān)推薦

2020-12-17 12:42:24

CentOSRHEL以太網(wǎng)卡

2009-12-17 13:30:57

Linux以太網(wǎng)卡

2010-04-21 17:56:22

Unix網(wǎng)卡配置

2018-11-06 15:22:39

網(wǎng)卡Mellanox以太網(wǎng)

2018-10-25 15:49:56

Mellanox太網(wǎng)卡存儲

2019-04-02 14:55:12

Linux虛擬網(wǎng)卡

2022-09-20 11:32:32

以太網(wǎng)電纜基礎(chǔ)網(wǎng)絡

2022-09-26 09:17:01

以太網(wǎng)電纜

2009-12-04 14:49:34

如何選擇無線路由器

2020-12-03 08:37:38

TCPIPARP協(xié)議

2010-08-11 12:27:19

無線路由選擇

2012-09-26 15:46:51

網(wǎng)絡

2010-03-22 10:41:50

2018-01-16 16:11:35

以太網(wǎng)

2012-12-28 09:08:36

光纖虛擬網(wǎng)絡存儲網(wǎng)絡

2013-12-19 09:16:15

以太網(wǎng)結(jié)構(gòu)以太網(wǎng)

2020-04-23 16:25:04

以太網(wǎng)800Gb技術(shù)規(guī)范

2023-05-22 10:09:03

以太網(wǎng)

2017-06-07 15:16:03

Windows 10Windows以太網(wǎng)圖標

2010-03-17 16:52:57

點贊
收藏

51CTO技術(shù)棧公眾號