The Sysadmin's Daily Grind: Ethtool

Negotiations


A touchy LAN that plays like a movie diva can spoil any admin's day. Ethtool to the rescue!

By Charly Kühnast

Murphy got on the bus I was riding a couple of days ago and followed me into my apartment. When I fired up my laptop, Murphy's Law struck. My harmless plan was to watch TV via streaming from my office. I have a VDR [1] set up in my lounge for this purpose, and a well-kept home network [2] between the lounge and the office to handle the rest. But the performance was so jerky, I really thought I was watching a breakdancing movie.

A (fairly exhaustive) diagnosis of the network hardware failed to reveal broken components. My switch is a dumb device without management functionality, so there was nothing to diagnose. What finally helped me save the day was Ethtool [3].

Automatic negotiation of the transmission parameters between the switch and my laptop's Gigabit port had failed. This failure not only resulted in a 100 Mbps connection rather than ten times that speed, but the failure also set the transmission mode to half-duplex (see Figure 1). No wonder the transfer rate was so slow.

Figure 1: Ethtool finds out why a full-duplex Gigabit LAN connection fails to happen.

Autonegotiation

Autonegotiation errors are a classical case of Murphy's law. They happen enough to get on your nerves, but not often enough to be automatic troubleshooting candidates. Sometimes errors can just disappear when you pull the cables and re-patch, as this initiates autoneg, but sometimes the errors persist. Network engineers have experienced situations in which ten NICs by the same vendor were attached to the same switch. Autoneg worked for seven of the cards, and it didn't work for the other three.

The worst thing is that everything seems to be fine at first. The link LED lights up, you get prompt responses to pings. Looks good, until you start to transmit larger volumes of data via the interface. You might be lucky, and actually notice the collision detection count when you run ifconfig. Collisions should not occur on a switched network. If they do, you are probably looking at a half-duplex connection.

Repair Mode

Luckily, Ethtool not only diagnoses this kind of error; it can actually remove it. The ethtool -r eth0 command relaunches autonegotiation, giving you a solution that is far more convenient than pulling the wires. In fact, this is your only vector if you do not have physical access to the hardware. I just don't trust autoneg any more, and this is why I hard-wire the values, like this:

ethtool -s eth0 speed 1000 duplex full autoneg off

If you have a managed switch (I don't), you can hard-wire the values at the switch.

More Tricks

Ethtool has a few more tricks up its sleeve. For instance, Ethtool gives you granular control over WOL (Wake On LAN) settings.

There is another function that looks like a nice but useless gimmick at first sight. The ethtool -p eth0 command tells a NIC to flash its LED on and off. If you have ever been faced with a server that had eight NICs, and not had a clue which one is eth0, you might appreciate this feature. Of course, a flashing LED is no replacement for a good evening's televiewing.

INFO
[1] VDR: http://www.cadsoft.de/vdr/
[2] If this column was available as a Podcast, readers could listen to my wife at this description of my home network as "well-kept."
[3] Ethtool: http://freshmeat.net/redir/ethtool/20128/url_homepage/gkernel
THE AUTHOR

Charly Kühnast is a Unix System Manager at the data-center in Moers, near Germany's famous River Rhine. His tasks include ensuring firewall security and availability and taking care of the DMZ (demilitarized zone).