原文链接
查看网卡速度有两个命令都可以查看:

mii-tool
eth0: negotiated 1000baseT-FD flow-control, link ok

这表示,eth0网卡的速度为1000M,并且是全双工工作模式,也可以使用

ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: yes

Speed 后边的数值就是速度,Duplex后边就是工作不是,full表示全双工,如果是half则表示半双工模式;Auto-negotiation 后边表示是否自动协商

那么如何调整网卡的速度以及工作模式?
修改linux网卡的工作模式:

ethtool –r ethX                    ## 重置ethX网口到自适应模式
ethtool –S ethX                    ## 查询ethX网口收发包统计
ethtool –s ethX [speed 10|100|1000]        ## 设置网口速率10/100/1000M
   [duplex half|full]                ## 设置网口半/全双工
   [autoneg on|off]                ## 设置网口是否自协商

下面的命令会把eth0设置成全双工非自动协商工作模式,并且速度为100M

ethtool -s eth0 duplex full autoneg off speed 100

设置网卡工作模式开机为全双工的方法:
一:
在/etc/sysconfig/network-script/ifcfg-ethX加入下面这句:

ETHTOOL_OPTS="speed 100 duplex full autoneg off"

二:
将上面的命令写入到/etc/rc.local里面。

ethtool -s eth0 duplex full autoneg off speed 100
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐