Chinaunix首页 | 论坛 | 博客
  • 博客访问: 159519
  • 博文数量: 31
  • 博客积分: 2025
  • 博客等级: 大尉
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-09 15:21
文章分类

全部博文(31)

文章存档

2011年(1)

2010年(1)

2009年(29)

我的朋友

分类: LINUX

2009-10-09 15:31:59

过去一直未重视这个命令,今天看到陈大师用这个命令来查看某个网口的收发包情况,甚为惊叹,google一下,发现这个命令的好处真多,学习一下。
 
Linux/Unix命令之Ethtool
来自: 杨志刚 博客 (http://yangzhigang.cublog.cn)

描述:
Ethtool是用于查询及设置网卡参数的命令。

概要:
ethtool ethX      //查询ethX网口基本设置
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]\         //设置网口速率10/100/1000M
[duplex half|full]\           //设置网口半/全双工
[autoneg on|off]\            //设置网口是否自协商
[port tp|aui|bnc|mii]\         //设置网口类型
[phyad N]\                
[xcvr internal|exteral]\
[wol p|u|m|b|a|g|s|d...]\
[sopass xx:yy:zz:aa:bb:cc]\
[msglvl N]

举例:
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)[root@linux /]# ethtool -s eth1 autoneg off speed 100 duplex full

相关:
1)[root@linux /]# which ethtool
    /sbin/ethtool
2)[root@linux /]# rpm -qf /sbin/ethtool
   ethtool-1.6-5
3)怎样使ethtool设置永久保存在网络设备中?
   解决方法一:
    ethtool设置可通过/etc/sysconfig/network-scripts/ifcfg-ethX文件保存,从而在设备下次启动时激活选项。
例如:ethtool -s eth0 speed 100 duplex full autoneg off
此指令将eth0设备设置为全双工自适应,速度为100Mbs。若要eth0启动时设置这些参数, 修改文件/etc/sysconfig/network-scripts/ifcfg-eth0 ,添加如下一行:
 ETHTOOL_OPTS="speed 100 duplex full autoneg off"
解决方法二:
将ethtool设置写入/etc/rc.d/rc.local之中。
---------------------------华丽的分割线-----------------------------------------
ETHTOOL(8)
 
NAME
       ethtool - Display or change ethernet card settings
SYNOPSIS
       ethtool ethX
       ethtool -h
       ethtool -a ethX
       ethtool -A ethX [autoneg on|off] [rx on|off] [tx on|off]
       ethtool -c ethX
       ethtool  -C 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]
       ethtool -g ethX
       ethtool -G ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]
       ethtool -i ethX
       ethtool -d ethX
       ethtool -e ethX [raw on|off] [offset N] [length N]
       ethtool -E ethX [magic N] [offset N] [value N]
       ethtool -k ethX
       ethtool -K ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off]
       ethtool -p ethX [N]
       ethtool -r ethX
       ethtool -S ethX
       ethtool -t ethX [offline|online]
       ethtool     -s     ethX     [speed 10|100|1000]      [duplex half|full]
       [port tp|aui|bnc|mii]  [autoneg on|off] [phyad N] [xcvr internal|exter-
       nal] [wol p|u|m|b|a|g|s|d...]  [sopass xx:yy:zz:aa:bb:cc] [msglvl N]
DESCRIPTION
       ethtool is used for querying settings of an ethernet device and  chang-
       ing them.
       ethX is the name of the ethernet device to work on.

OPTIONS
       ethtool  with  a single argument specifying the device name prints cur-
       rent setting of the specified device.
       -h     shows a short help message.
       -a     queries the specified ethernet device for pause parameter infor-
              mation.
       -A     change the pause parameters of the specified ethernet device.
       autoneg on|off
              Specify if pause autonegotiation is enabled.
       rx on|off
              Specify if RX pause is enabled.
       tx on|off
              Specify if TX pause is enabled.
       -c     queries  the  specified  ethernet device for coalescing informa-
              tion.
       -C     change the coalescing settings of the specified ethernet device.
       -g     queries  the  specified ethernet device for rx/tx ring parameter
              information.
       -G     change the rx/tx  ring  parameters  of  the  specified  ethernet
              device.
       rx N   Change number of ring entries for the Rx ring.
       rx-mini N
              Change number of ring entries for the Rx Mini ring.
       rx-jumbo N
              Change number of ring entries for the Rx Jumbo ring.
       tx N   Change number of ring entries for the Tx ring.
       -i     queries  the  specified  ethernet  device  for associated driver
              information.
       -d     retrieves and prints a register dump for the specified  ethernet
              device.
       -e     retrieves  and  prints an EEPROM dump for the specified ethernet
              device.  When raw is enabled, then it dumps the raw EEPROM  data
              to  stdout.  The length and offset parameters allow dumping cer-
              tain portions of the EEPROM.  Default is to dump the entire EEP-
              ROM.
       -E     Changes  EEPROM  byte for the specified ethernet device.  offset
              and value specify which byte and it's new value.  Because of the
              persistent  nature  of  writing to the EEPROM, a device-specific
              magic key must be specified to prevent the accidental writing to
              the EEPROM.
       -k     queries the specified ethernet device for offload information.
       -K     change  the offload parameters of the specified ethernet device.
       rx on|off
              Specify if RX checksumming is enabled.
       tx on|off
              Specify if TX checksumming is enabled.
       sg on|off
              Specify if scatter-gather is enabled.
       tso on|off
              Specify if tcp segmentation offload is enabled.
       -p     initiates 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  ethernet
              port.
       N      Length of time to perform phys-id, in seconds.
       -r     restarts  auto-negotiation  on the specified ethernet device, if
              auto-negotiation is enabled.
       -S     queries the specified ethernet device for NIC-  and  driver-spe-
              cific statistics.
       -t     executes adapter selftest on the specified ethernet device. Pos-
              sible test modes are:
       offline|online
              defines test type: offline (default) means to perform  full  set
              of  tests  possibly causing normal operation interruption during
              the tests, online means to perform limited set of tests  do  not
              interrupting normal adapter operation.
       -s     option  allows  changing  some  or all settings of the specified
              ethernet device.  All following options only  apply  if  -s  was
              specified.
       speed 10|100|1000
              Set  speed  in Mb/s.  ethtool with single argument will show you
              the supported device speeds.
       duplex half|full
              Set full or half duplex mode.
       port tp|aui|bnc|mii
              Select device port.
       autoneg on|off
              Specify if autonegotiation is enabled. In the usual case it  is,
              but  might cause some problems with some network devices, so you
              can turn it off.
       phyad N
              PHY address.
       xcvr internal|external
              Select transceiver type. Currently only  internal  and  external
              can be specified, in the future further types might be added.
       wol p|u|m|b|a|g|s|d...
              Set  Wake-on-LAN  options.   Not  all devices support this.  The
              argument to this option is a  string  of  characters  specifying
              which options to enable.
              p  Wake on phy activity
              u  Wake on unicast messages
              m  Wake on multicast messages
              b  Wake on broadcast messages
              a  Wake on ARP
              g  Wake on MagicPacket(tm)
              s  Enable SecureOn(tm) password for MagicPacket(tm)
              d  Disable  (wake  on nothing).  This option clears all previous
                 options.
       sopass xx:yy:zz:aa:bb:cc
              Set the SecureOn(tm) password.  The argument to this option must
              be 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc).
       msglvl N
              Set the driver message level. Meanings differ per driver.
BUGS
       Not supported (in part or whole) on all ethernet drivers.
AUTHOR
       ethtool was written by David Miller.
       Modifications by Jeff Garzik, Tim Hockin, Jakub Jelinek, Andre Majorel,
       Eli Kupermann, Scott Feldman.
AVAILABILITY
       ethtool  is  available  over  the  Web  on  the  SourceForge  site   at
      

阅读(2125) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~