• ethtool的基本设置


     ethtool是设置网卡属性、IP/TCP相关协议属性的基本工具,功能还是很强大的。ubuntu的版本里没有默认集成,使用apt-get install 安装之。。。。

    使用概要:
    ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等
    ethtool –h        //显示ethtool的命令帮助(help)
    ethtool –i ethX    //查询ethX网口的相关信息 
    ethtool –d ethX    //查询ethX网口注册性信息
    ethtool –r ethX    //重置ethX网口到自适应模式
    ethtool –S ethX    //查询ethX网口收发包统计
    ethtool –s ethX [speed 10|100|1000] [duplex half|full]  [autoneg on|off]        //设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商

    ethtool -k      //查看protocol offload的属性

    ethtool -K|--offload DEVNAME Set protocol offload  // 设置protocol offload的属性,这个命令很强大,待会再讲

    [ rx on|off ]
    [ tx on|off ]
    [ sg on|off ]
    [ tso on|off ]
    [ ufo on|off ]
    [ gso on|off ]
    [ gro on|off ]
    [ lro on|off ]
    [ rxvlan on|off ]
    [ txvlan on|off ]
    [ ntuple on|off ]
    [ rxhash on|off ]

    使用举例:


    1)[root@linux /]# ethtool eth1
       Settings for eth1:
            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: d
            Link detected: yes

    2)[root@linux /]# ethtool -i eth1
       driver: e1000
       version: 5.0.43-k1
       firmware-version: N/A
       bus-info: 06:08.1


    3)[root@linux /]# ethtool -S eth1
       NIC statistics:
         rx_packets: 58068300
         tx_packets: 87124083
         rx_bytes: 1589713008
         tx_bytes: 2165825901
         rx_errors: 0
         tx_errors: 0
         rx_dropped: 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_fifo_errors: 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

    4) 把网卡eth0 速度改为10Mb/s,采用半双工;

    [root@cuc03 beinan]# ethtool -s eth1 speed 10 duplex half
    [root@cuc03 beinan]# ethtool eth1
    Settings for eth1:
    Supported ports: [ TP MII ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Advertised auto-negotiation: No
    Speed: 10Mb/s 注:速度 10M/s
    Duplex: Half 注:半双工
    Port: MII
    PHYAD: 32
    Transceiver: internal
    Auto-negotiation: off
    Supports Wake-on: pumbg
    Wake-on: d
    Current message level: 0x00000007 (7)
    Link detected: no 注:eth1没有激活;

    5)把网卡eth0 速度改为100Mb/s,采用全双工;
    [root@cuc03 beinan]# ethtool -s eth1 speed 100 duplex full 
    [root@cuc03 beinan]# ethtool eth1
    Settings for eth1:
    Supported ports: [ TP MII ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Advertised auto-negotiation: No
    Speed: 100Mb/s 注:速度 100M/s
    Duplex: Full 注:全双工
    Port: MII
    PHYAD: 32
    Transceiver: internal
    Auto-negotiation: off
    Supports Wake-on: pumbg
    Wake-on: d
    Current message level: 0x00000007 (7)
    Link detected: no 注:eth1网卡没有激活;

    6) 最后关于这个ethtool -k eth0 就特别说明一下,这个是显示网卡的一些特别的协议开关

    root@node4:/home/fbw# ethtool -k eth0
    Offload parameters for eth0:
    rx-checksumming: on
    tx-checksumming: off
    scatter-gather: off
    tcp-segmentation-offload: off
    udp-fragmentation-offload: off
    generic-segmentation-offload: off
    generic-receive-offload: on
    large-receive-offload: off
    rx-vlan-offload: on
    tx-vlan-offload: on
    ntuple-filters: off
    receive-hashing: on

       特别注意,加红的那个参数,之前看到别人遇到这个问题,在部署OpenStack的计算节点的时候,如何将computer部署在台式机上,ssh连接虚拟机就特别卡,连接超时将近1多钟,但是如果将其部署在刀片上就没有任何问题。于是,后面将问题定位到台式机的BCM的网卡上,发现只要敲一下 ethtool -K eth0 tx off ,即只要关掉包发送校检和,就可以正常ssh连接。


  • 相关阅读:
    Java基础算法--排序
    Java基础之String类的细节问题
    Java数据结构四之——二叉树的前、中、后序遍历
    动态规划之----最长公共子序列(LCS)
    最长公共子串问题
    makefile学习笔记
    使用正则表达式,去除C++的注释
    gbk字库音序对照表
    Fsharp 类中的空字段
    使用FSharp 探索Dotnet图像处理功能2--均衡灰度
  • 原文地址:https://www.cnblogs.com/fbwfbi/p/3612658.html
Copyright © 2020-2023  润新知