The Ethtool command is used to change Ethernet adapter settings. With the use of this command, you can change network card speed, auto-negotiation, wake on LAN setting, duplex mode etc. It is helpful to have some information about a particular network adaptor, specially in checking the software for compatibility. It is not available by default in installation. So, you need to install it from repositories.
The Ethtool command retrieves the status of Ethernet interface and provides it as an argument.
Given below is an example:
[[email protected] ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
Advertised auto-negotiation: Yes
Port: Twisted Pair
Supports Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes
The output given above displays properties like speed, duplex, status and wake on for the etho interface.
There are three types of duplexes:
Full Duplex: Used when the Ethernet is connected to the switch. Allows two- way transfers, that is, sending and receiving of packets simultaneously.
Half Duplex: Used when the Ethernet is in connection with the hub. Allows only one- way transfers, that is, either sending or receiving of packets.
Auto negotiation: On the basis of the network connection, the Ethernet interface decides whether to use full or half duplex.
The Ethtool command can be set permanently with the Ethtool_opt variable. Let us have a look at the example given below:
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
ETHTOOL_OPTS="speed 50 duplex full autoneg off"
You can test the above setting with ifup and ifdow commands.
The Ethernet driver settings and autonegotiation can be checked with the following commands:
[[email protected] ~]# ethtool -i eth0
[[email protected] ~]# ethtool –a eth0
Pause parameters for eth0:
The '–p option' of Ethtool command helps to identify specific device from multiple devices.
[[email protected] ~]# ethtool –p eth0
Having the statistics of network card is very useful in troubleshooting of network issues.
[[email protected] ~]# ethtool –S eth0
The output above shows the details about the transferred and received packets.
Flow control in full duplex can be enabled by PAUSE parameter in latest MAC and GMAC embedded devices.
Here is the solution:
[[email protected] ~]#ethtool -A eth0 [autoneg on|off] [rx on|off] [tx on|off]
Offload parameters details can be obtained as follows:
[[email protected] ~]# ethtool –k eth0
However, any changes made in the Ethernet parameter settings will disappear at the time of the next boot. In order to have them intact in the next boot, you have to make these changes permanent by adding the command to /etc/rc.local
[[email protected] ~]#cat /etc/rc.local
ethtool -s eth0 speed 100 duplex full autoneg on 1>/dev/null 2>/dev/null
ethtool -s eth1 speed 100 duplex full autoneg on 1>/dev/null 2>/dev/null
Another example which sets the speed or duplex mode using ethtool command is as follows:
[[email protected] ~]# ethtool -s eth0 speed 100 duplex full
[[email protected] ~]# ethtool -s eth0 speed 10 duplex half