blockdev命令blkid命令badblocks命令fdisk命令du命令df命令convertquota命令lvcreate命令lsblk命令lilo命令hdparm命令grub命令lvremove命令lvreduce命令lvextend命令lvdisplay命令mkisofs命令mkinitrd命令mkbootdisk命令lvscan命令lvresize命令pvchange命令partprobe命令parted命令mkswap命令mknod命令pvs命令pvremove命令pvdisplay命令pvcreate命令pvck命令vgcreate命令vgconvert命令vgchange命令pvscan命令vgremove命令vgreduce命令vgextend命令vgdisplay命令fuser命令free命令dstat命令vgscan命令iotop命令iostat命令inotifywait命令ifstat命令nethogs命令mpstat命令ltrace命令lsof命令tload命令time命令strace命令sar命令arch命令vmstat命令uptime命令top命令losetup命令hwclock命令dmidecode命令cdrecord命令volname命令systool命令setpci命令lsusb命令lspci命令dmesg命令depmod命令bmodinfo命令lsmod命令kexec命令kernelversion命令insmod命令sysctl命令slabtop命令rmmod命令modprobe命令rcp命令ncftp命令ftp命令uname命令dump命令cpio命令tftp命令scp命令bunzip2命令arj命令restore命令bzip2命令bzgrep命令bzdiff命令bzcmp命令bzcat命令compress命令bzmore命令bzless命令bzip2recover命令tar命令lha命令gzip命令gzexe命令gunzip命令zcat命令unzip命令uncompress命令unarj命令znew命令zipsplit命令zipinfo命令zip命令zfore命令csplit命令comm命令colrm命令col命令fgrep命令expand命令egrep命令diffstat命令ispell命令grep命令fold命令fmt命令printf命令pr命令paste命令look命令join命令tac命令split命令spell命令sort命令rev命令uniq命令unexpand命令tr命令tee命令chgrp命令chattr命令wc命令lsattr命令file命令dos2unix命令chown命令chmod命令umask命令stat命令setfacl命令joe命令jed命令ex命令emacs命令ed命令vi命令sed命令pico命令nano命令hexdump命令head命令cut命令tail命令od命令more命令less命令find命令diff3命令diff命令cmp命令which命令whereis命令strings命令iconv命令dirname命令dd命令cat命令basename命令rename命令pathchk命令nl命令ln命令cd命令updatedb命令unlink命令touch命令ls命令install命令dirs命令cp命令pushd命令popd命令mv命令mkdir命令tree命令rmdir命令rm命令pwd命令gcov命令gcc命令expr命令as命令ldd命令ldconfig命令ld命令indent命令gdb命令objdump命令nm命令mktemp命令make命令readelf命令pstack命令protoize命令php命令perl命令apt-key命令apt-get命令unprotoize命令test命令chkconfig命令aptitude命令apt-sortpkgs命令dpkg-deb命令dpkg命令dnf命令dpkg-reconfigure命令dpkg-query命令dpkg-preconfigur命令dpkg-divert命令ntsysv命令dpkg-trigger命令dpkg-statoverrid命令dpkg-split命令rpm2cpio命令rpm命令rcconf命令patch命令rpmverify命令rpmsign命令rpmquery命令rpmdb命令rpmbuild命令cupsdisable命令cancel命令accept命令yum命令lpadmin命令lp命令eject命令cupsenable命令lpstat命令lprm命令lpr命令lpq命令lpc命令dnsdomainname命令dhclient命令reject命令ifcfg命令hostname命令ethtool命令domainname命令mii-tool命令ifup命令ifdown命令ifconfig命令ypdomainname命令usernetctl命令route命令nisdomainname命令ssh命令sftp-server命令sftp命令nmap命令iptstate命令ssh-keygen命令ssh-copy-id命令ssh-agent命令ssh-add命令arping命令arp命令sshd命令ssh-keyscan命令iperf命令hping3命令host命令dig命令arpwatch命令tracepath命令ping命令nslookup命令netstat命令elinks命令curl命令axel命令traceroute命令lftp命令jwhois命令ipcalc命令elm命令mailstat命令mailq命令mail命令lynx命令lftpget命令rsh命令rlogin命令rexec命令telnet命令apachectl命令ab命令wget命令ftptop命令ftpshut命令ftpcount命令exportfs命令mysqladmin命令mysql命令htpasswd命令htdigest命令ftpwho命令nfsstat命令mysqlshow命令mysqlimport命令mysqldump命令squid命令smbpasswd命令smbclient命令showmount命令sendmail命令ip命令arptables命令arpd命令squidclient命令iptables命令ip6tables-save命令ip6tables-restor命令ip6tables命令pfctl命令lnstat命令iptraf命令iptables-save命令iptables-restore命令tcpreplay命令tcpdump命令ss命令shutdown命令reboot命令poweroff命令halt命令ctrlaltdel命令restorecon命令getsebool命令chcon命令setsebool命令sesearch命令semanage命令seinfo命令xhost命令xclip命令xauth命令startx命令xlsfonts命令xlsclients命令xlsatoms命令xinit命令chpasswd命令chfn命令chage命令xset命令groupadd命令gpasswd命令finger命令chsh命令grpconv命令grpck命令groups命令groupmod命令groupdel命令newusers命令logname命令id命令grpunconv命令pwconv命令pwck命令passwd命令nologin命令userdel命令useradd命令su命令pwunconv命令atq命令at命令usermod命令ipcrm命令init命令crontab命令batch命令atrm命令nohup命令nice命令killall命令ipcs命令pkill命令pidof命令pgrep命令renice命令pstree命令ps命令pmap命令telint命令systemctl命令skill命令service命令runlevel命令alias命令watch命令w命令builtin命令bind命令bg命令apropos命令echo命令dris命令declare命令command命令export命令exit命令exec命令env命令enable命令history命令help命令fg命令fc命令read命令logout命令let命令kill命令jobs命令shopt命令sh命令set命令seq命令readonly命令ulimit命令type命令trap命令tput命令wait命令unset命令unalias命令cksum命令cal命令bc命令awk命令clear命令date命令consoletype命令clockdiff命令gpm命令dircolors命令hostid命令login命令info命令mesg命令md5sum命令man命令ngrep命令mtools命令ntpdate命令rsync命令pssh命令screen命令sum命令stty命令speedtest-cli命令sleep命令vdfuse命令users命令tempfile命令talk命令whoami命令who命令whatis命令wall命令dumpe2fs命令yes命令xargs命令write命令edquota命令e2label命令e2image命令e2fsck命令mkfs命令mke2fs命令fsck命令findfs命令quotaoff命令quotacheck命令quota命令mountpoint命令mount命令resize2fs命令repquota命令quotastats命令quotaon命令tune2fs命令sync命令swapon命令swapoff命令umount命令

ethtool命令

ethtool命令用于获取以太网卡的配置信息,或者修改这些配置。这个命令比较复杂,功能特别多。

语法

ethtool [ -a | -c | -g | -i | -d | -k | -r | -S |] ethX
ethtool [-A] ethX [autoneg on|off] [rx on|off] [tx on|off]
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-lowN] [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 [rx N] [rx-mini N] [rx-jumbo N] [tx N]
ethtool [-e] ethX [raw on|off] [offset N] [length N]
ethtool [-E] ethX [magic N] [offset N] [value N]
ethtool [-K] ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off]
ethtool [-p] ethX [N]
ethtool [-t] ethX [offline|online]
ethtool [-s] ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] [port tp|aui|bnc|mii] [phyad N] [xcvr internal|external]
[wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

选项

-a 查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-A 修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-c display the Coalesce information of the specified ethernet card。
-C Change the Coalesce setting of the specified ethernet card。
-g Display the rx/tx ring parameter information of the specified ethernet card。
-G change the rx/tx ring setting of the specified ethernet card。
-i 显示网卡驱动的信息,如驱动的名称、版本等。
-d 显示register dump信息, 部分网卡驱动不支持该选项。
-e 显示EEPROM dump信息,部分网卡驱动不支持该选项。
-E 修改网卡EEPROM byte。
-k 显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。
-K 修改网卡Offload参数的状态。
-p 用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。
-r 如果auto-negotiation模块的状态为on,则restarts auto-negotiation。
-S 显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t 让网卡执行自我检测,有两种模式:offline or online。
-s 修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等。

数据来源

Ethtool命令显示的信息来源于网卡驱动层,即TCP/ip协议的链路层。该命令在Linux内核中实现的逻辑层次为:

最重要的结构体struct ethtool_ops,该结构体成员为用于显示或修改以太网卡配置的一系列函数指针,见下表中的第二列。

网卡驱动负责实现(部分)这些函数,并将其封装入ethtool_ops结构体,为网络核心层提供统一的调用接口。因此,不同的网卡驱动会给应用层返回不同的信息。Ethtool命令选项struct ethtool_ops成员函数Ethtool命令显示参数的来源,三者间的对应关系如下表所示:

命令选项 struct ethtool_ops成员函数 Ethtool命令显示参数的来源(以网卡驱动BNX2为例)
无 -s get_settingsget_wol get_msglevel get_link set_settings set_wol set_msglevel 从网卡寄存器中获得网卡速度等信息,可配置。
-a -A get_pauseparam set_pauseparam 从网卡寄存器中获得Autonegotiate/RX/TX模块的状态:on oroff,可配置。
-c -C get_coalesceset_coalesce 从网卡寄存器中获得coalescing参数:TX/RX一个数据包后,推迟发生TX/RX中断的时间(us)/数据包个数。—减小该值可以提高网卡的响应时间。 当rx-usecs&rx-frames同时被设为0时,RX中断停止。 当tx-usecs&tx-frames同时被设为0时,TX中断停止。
-g -G get_ringparam set_ringparam 除当前TX/RX ring的值(从网卡寄存器中读取得到,可配置)外,其它为网卡bnx2自己固定的信息。
-k -K get_rx_csumget_tx_csum get_sg get_tso set_rx_csum set_tx_csum set_sg set_tso 显示信息从保存该状态的变量中读取得到,没有对应的寄存器。因此,TX/RX校验等模块一直处于on状态,实际上是无法修改的。
-i get_drvinfo[self_test_count, get_stats_coun,t get_regs_len, get_eeprom_len] 网卡bnx2自己固定的信息,如: ——————————————————– driver: bnx2 version: 1.4.30 firmware-version: 1.8.0.5 bus-info: 0000:09:00.0 ——————————————————–
-d get_drvinfoget_regs 不支持,即bnx2中没有实现函数get_regs。
-e -E get_eepromset_eeprom 不支持,即bnx2中没有实现函数get_eeprom。
-r nway_reset 配置网卡MII_BMCR寄存器,重启Auto negotiation模块。
-p phys_id 配置网卡BNX2_EMAC_LED寄存器,实现LED闪功能。
-t self_test 通过配置网卡寄存器,逐一测试网卡的硬件模块:registers,memory,loopback,Link stat,interrupt。
-S get_ethtool_stats 显示信息来源于网卡驱动中的结构体变量stats_blk。(网卡通过DMA方式,将寄存器BNX2_HC_STATISTICS _ADDR_L和BNX2_HC_STATISTICS_ADDR_H中的数据实时地读取到结构体变量struct statistics_block *stats_blk中。) —显示的数据都是从网卡寄存器中统计得到的,各项的含义需查询网卡(芯片)手册。

由上可见,ethtool命令用于显示/配置网卡硬件(寄存器)。  

实例

查看机器上网卡的速度:百兆还是千兆,请输入:

ethool eth0

操作完毕后,输出信息中Speed:这一项就指示了网卡的速度。停止网卡的发送模块TX,请输入:

ethtool -A tx off eth0

操作完毕后,可输入ethtool -a eth0,查看tx模块是否已被停止。查看网卡eth0采用了何种驱动,请输入:

ethtool -i eth0

操作完毕后,显示 driver: bnx2;version: 1.4.30 等信息。关闭网卡对收到的数据包的校验功能,请输入:

ethtool -K eth0 rx off

操作完毕后,可输入ethtool –k eth0,查看校验功能是否已被停止。如果机器上安装了两块网卡,那么eth0对应着哪块网卡呢?输入:

ethtool -p eth0 10

操作完毕后,看哪块网卡的led灯在闪,eth0就对应着哪块网卡。查看网卡,在接收/发送数据时,有没有出错?请输入:

ethtool –S eth0

将千兆网卡的速度降为百兆,请输入:

ethtool -s eth0 speed 100