Ethtool
Instal·lació
$ sudo apt-get install ethtool
Els fitxers instal·lat són:
$ dpkg -L ethtool /. /usr /usr/sbin /usr/sbin/ethtool /usr/share /usr/share/man /usr/share/man/man8 /usr/share/man/man8/ethtool.8.gz /usr/share/doc /usr/share/doc/ethtool /usr/share/doc/ethtool/AUTHORS /usr/share/doc/ethtool/README /usr/share/doc/ethtool/README.Debian /usr/share/doc/ethtool/copyright /usr/share/doc/ethtool/changelog.gz /usr/share/doc/ethtool/NEWS.gz /usr/share/doc/ethtool/changelog.Debian.gz
Exemples
Ús bàsic
Mostra les dades de nivell d'interfície d'una interfície de xarxa:
$ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pg Wake-on: g Current message level: 0x00000037 (55) Link detected: yes
Comprovar si hi ha link
Si teniu problemes de xarxa, el primer que s'hauria de comprovar és si teniu link:
$ sudo ethtool eth0 | grep Link Link detected: yes
Conèixer el driver de la targeta de xarxa
$ sudo ethtool -i eth0 driver: skge version: 1.13 firmware-version: N/A bus-info: 0000:02:08.0
bus-info:
0000:02:08.0, s'interpreta com:
- Bus 2 (0000:02)
- Dispositiu 8
- Funció 0
Identificar la targeta (fer parpallejar la llum de link)
Es pot utilitzar per identificar una targeta de xarxa. Desconnecteu el cable i executeu:
$ sudo ethtool -p eth0 10
Forçareu que parpellegi la llum i identificareu la interfície.
Renegociar l'enllaç
A part de ser una comanda de consulta també permet fer modificacions de la targeta de xarxa (com per exemple activar Wake On LAN, paràmetres de la interfície, autonegociació, etc.). Per exemple es pot tornar a renegociar l'enllaç amb:
$ sudo ethtool -r eth0
Realitzar un test
O fer un test (no totes les targetes ho suporten) amb:
$ sudo ethtool --test eth0 The test result is FAIL The test extra info: link (online/offline) 1 register (offline) 0 interrupt (offline) 0 loopback (offline) 0
Configurar manualment la interfície de xarxa
La següent comanda:
$ sudo ethtool -s eth0 speed 10 duplex full autoneg off
Estableix la velocitat a 10MB, full duplex i autonegociació aturada. Observeu les diferències del temps de ping amb 1Gbps:
$ sudo ethtool -s eth0 speed 1000 duplex full autoneg off $ ping 192.168.111.100 PING 192.168.111.100 (192.168.111.100) 56(84) bytes of data. 64 bytes from 192.168.111.100: icmp_req=1 ttl=64 time=0.193 ms 64 bytes from 192.168.111.100: icmp_req=2 ttl=64 time=0.212 ms 64 bytes from 192.168.111.100: icmp_req=3 ttl=64 time=0.170 ms 64 bytes from 192.168.111.100: icmp_req=4 ttl=64 time=0.214 ms
100 mbps:
$ sudo ethtool -s eth0 speed 100 duplex full autoneg off
i 10mpbs:
$ sudo ethtool -s eth0 speed 10 duplex full autoneg off PING 192.168.111.100 (192.168.111.100) 56(84) bytes of data. 64 bytes from 192.168.111.100: icmp_req=3 ttl=64 time=0.715 ms 64 bytes from 192.168.111.100: icmp_req=4 ttl=64 time=1.25 ms 64 bytes from 192.168.111.100: icmp_req=5 ttl=64 time=0.658 ms 64 bytes from 192.168.111.100: icmp_req=6 ttl=64 time=0.655 ms 64 bytes from 192.168.111.100: icmp_req=7 ttl=64 time=0.677 ms 64 bytes from 192.168.111.100: icmp_req=8 ttl=64 time=0.661 ms
Observeu també els canvis de color del led del commutador (en la majoria de commutadors).
Ho podeu comprovar amb:
$ sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised auto-negotiation: Yes Speed: 10Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: off Supports Wake-on: pg Wake-on: g Current message level: 0x00000037 (55) Link detected: yes
Consultar les estadístiques de la targeta de xarxa
$ sudo ethtool -S eth0 NIC statistics: tx_bytes: 19273311 rx_bytes: 47534787 tx_broadcast: 1494 rx_broadcast: 753 tx_multicast: 365 rx_multicast: 1635 tx_unicast: 69413 rx_unicast: 72151 tx_mac_pause: 0 rx_mac_pause: 0 collisions: 0 multi_collisions: 0 aborted: 0 late_collision: 0 fifo_underrun: 0 fifo_overflow: 0 rx_toolong: 0 rx_jabber: 0 rx_runt: 0 rx_too_long: 0 rx_fcs_error: 48
Opcions ethtool
En sistemes com Red HAT o Fedora es poden canviar aquests paràmetres al fitxer /etc/sysconfig/network-scripts/ifcfg-eth0:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"
En Debian o sistemes de la família simplement podeu executar scripts de configuració utilitzant les carpetes :
- /etc/network/if-down.d
- /etc/network/if-post-down.d
- /etc/network/if-pre-up.d
- /etc/network/if-up.d
O utilitzant les opcions pre-up o similar directament al fitxer /etc/network/interfaces.
Recursos:
Wake ON LAN
Consulteu l'article WOL._Wake_on_Lan
Mii (Medium Independence Interface)
Mii són les inicials de (Medium Independence Interface).
Diferents components:
- DTE: Data Terminal Equipment
- MII: Media Independent Interface
- PHY: PHYsical Layer
Fitxer:Ch9 enet confg AFrame 5.gif
Recursos:
- http://www.ethermanage.com/ethernet/100quickref/ch9qr_7.html
- http://en.wikipedia.org/wiki/Media_Independent_Interface
mii-tool
Proporciona informació similar a ethtool:
$ sudo mii-tool eth0: negotiated 100baseTx-FD flow-control, link ok
Però no cal instal·lar-lo perquè normalment esta instal·lat (forma part del mateix paquet d'ifconfig):
$ dpkg -S mii-tool net-tools: /usr/share/man/man8/mii-tool.8.gz net-tools: /sbin/mii-tool
$ sudo apt-get install net-tools
$ dpkg -L net-tools /. /usr /usr/sbin /usr/sbin/arp /usr/share /usr/share/man /usr/share/man/man5 /usr/share/man/man5/ethers.5.gz /usr/share/man/man8 /usr/share/man/man8/mii-tool.8.gz /usr/share/man/man8/nameif.8.gz /usr/share/man/man8/netstat.8.gz /usr/share/man/man8/plipconfig.8.gz /usr/share/man/man8/rarp.8.gz /usr/share/man/man8/route.8.gz /usr/share/man/man8/arp.8.gz /usr/share/man/man8/ifconfig.8.gz /usr/share/man/man8/slattach.8.gz /usr/share/doc /usr/share/doc/net-tools /usr/share/doc/net-tools/README /usr/share/doc/net-tools/README.ipv6 /usr/share/doc/net-tools/TODO /usr/share/doc/net-tools/copyright /usr/share/doc/net-tools/changelog.Debian.gz /sbin /sbin/ifconfig /sbin/nameif /sbin/plipconfig /sbin/rarp /sbin/route /sbin/slattach /sbin/ipmaddr /sbin/iptunnel /sbin/mii-tool /bin /bin/netstat
Consulteu el manual:
$ man mii-tool
Alguns exemples del que es pot fer amb mii-tool:
Controla l'estat:
$ sudo mii-tool -w eth0 14:16:26 eth0: negotiated 100baseTx-FD flow-control, link ok
Renegociar l'enllaç:
$ sudo mii-tool -r eth0 restarting autonegotiation...
mii-diag
Un altre alternativa
$ dpkg -S /usr/sbin/mii-diag mii-diag: /usr/sbin/mii-diag
S'instal·la doncs amb:
$ sudo apt-get install mii-diag
Exemple:
$ sudo mii-diag eth0 Basic registers of MII PHY #0: 1000 796d 0141 0c25 0de1 45e1 0005 2001. The autonegotiated capability is 01e0. The autonegotiated media type is 100baseTx-FD. Basic mode control register 0x1000: Auto-negotiation enabled. You have link beat, and everything is working OK. Your link partner advertised 45e1: Flow-control 100baseTx-FD 100baseTx 10baseT-FD 10baseT, w/ 802.3X flow control. End of basic transceiver information.