NoOps

Ops make no ops | Ops的目标是没有Ops,嗯!

ethtool命令及相关参数小解

作者: |   4,375 浏览  | 

Linux中ethtool命令的作用是查看或修改网卡参数。命令都不难,但是一些参数的意义并不能直观的理解。这两天查阅资料详细了解了ethtool一些常用参数的意义和作用,给大家分享。

# ethtool -a eth0 —— 显示eth0网卡的中断选项设置情况

Pause parameters for eth0:

Autonegotiate:  on —— 自动协商

RX:             on —— 接收模块

TX:             off ——发送模块

# ethtool -A|–pause ethX [autoneg on|off] [rx on|off] [tx on|off] ——设置网卡中断选项

关于中断的解释:

The latest MAC and GMAC embedded devices allow flow control in Full Duplex by using the PAUSE operation and control frame transmission. They also support flow control in Half Duplex by using back pressure.

 

#ethtool –c eth0 ——显示eth0的联合选项设置情况

# ethtool  -C|–coalesce  ethX [adaptive-rx on|off] [adaptive-tx on|off] [rx-usecs N] [rx-frames N] [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N] [tx-frames  N]  [tx-usecs-irq  N] [tx-frames-irq N] [stats-block-usecs N] [pkt-rate-low N] [rx-usecs-low N] [rx-frames-low N] [tx-usecs-low N] [tx-frames low  N]  [pkt-rate-high  N] [rx-usecs-high N] [rx-frames-high N] [tx-usecs-high N] [tx-frames-high N] [sample-interval N] ——对ethX进行联合选项设置

 

#ethtool –g eth0 ——显示eth0的回环参数

#ethtool –G eth0 ——设置eth0的回环参数

#ethtool –i eth0  ——显示eth0的驱动信息

 

#ethtool -d eth0 ——显示eth0的寄存器缓存设置

 

#ethtool –e eth0 ——显示eth0的eeprom-dump转存信息

#ethtool –E eth0 ——修改eth0的eeprom-dump转存信息

 

#ethtool –k eth0 ——显示eth0的Offload参数的状态

Offload parameters for eth0:

rx-checksumming: off

tx-checksumming: off

scatter-gather: off

tcp-segmentation-offload: off ——需要网卡支持,将大于MTU大小包的tcp包的分片工作交给网卡去做,节约cpu资源但是会延迟包传送

udp-fragmentation-offload: off

generic-segmentation-offload: on ——类似TSO,不仅支持tcp

generic-receive-offload: off ——网卡将满足一定条件(比较严格)的包,将分片组装合并成skb,一次性交给上面的协议栈。2.6.29-2.6.39之间的内核此参数和lvs有兼容性问题,2.6.39修复,所以还是关掉比较靠谱

large-receive-offload: off ——将多个TCP数据整合在一个skb结构中,并在稍后作为一个大的数据包交付给上层网络协议栈,减少中断数和上层协议栈处理skb的开销,提高Linux系统接收TCP数据包的能力

#ethtool –K eth0 ——修改eth0 offload参数

#ethtool -p eth0 5 ——比较有趣的一个命令,可以让物理网卡eth0闪烁5次,可以在物理上发现网卡的位置

#ethtool –r eth0 ——如果eth0设置的是端口自适应,则restart这个端口

#ethtool –S eth0 ——显示eth0的统计参数

#ethtool –t eth0 offline/online ——让eth0 自检

The test result is PASS

The test extra info:

Register test  (offline)      0

Eeprom test    (offline)      0

Interrupt test (offline)      0

Loopback test  (offline)      0

Link test   (on/offline)      0

#ethtool    -s   ethX   speed N   [duplex half|full]   [port tp|aui|bnc|mii][autoneg on|off]   [advertise   N]   [phyad   N]   [xcvr internal|external][wol p|u|m|b|a|g|s|d...]  [sopass xx:yy:zz:aa:bb:cc] [msglvl N] ——设置端口的一些属性

#ethtool -f –flash  FILE ——更新网卡固件

#ethtool –n  ethX [rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6] ——获取网卡接收网络流量分类的配置?这个命令测试2台机器的网卡貌似都不支持,不太明白意义,如果有知道的还请指教:)

2 Comments

  1. wilbur
    2013/05/17 at 11:26 上午

    wow

  2. 2013/07/20 at 5:43 下午

    ethtool还可以看网卡是全双工还是半双工,网卡速度等,很牛逼的一个工具

Tanky Woo 进行回复 取消回复