Fun with ethtool
Time to be honest here for a minute. The open source community really has outdone themselves coming up with some very obscure names for packages. Let's take this list of packages for instance: emacs, gimp, gcc, mutt, grub, kyle rankin, parted, tar, mutt, vim. Nine times out of ten, a common person is going to look at that list and become utterly confused over what package does what. That's just the beauty (and beast) of naming software in the open source community. But every so often a tool comes across my screen with such a blatantly obvious name that I just have to run a 'man' to make sure my eyes are not deceiving me. In this case, it's ethtool. Yes, a simple name, for such a powerful utility. The name itself tells you what it does, an Ethernet Tool. Tada! That's it, ethernet tool.
What Ethtool does is allows you to modify your Ethernet adapter settings inside of Linux. What I'll be writing about today isn't the nitty gritty of ethernet adaptors (coalesce, setting rings, register dumping, etc). But what I will address are some really nifty tips and tricks I have learned over the last decade or so.
So without further adieu, let's get started. First things first we need to determine what Ethernet adaptor you are using.
ifconfig
Keep in mind though, ethtool will only work against physical ethernet adapters. This means that bond0, tun0, and any other network device that is not a physical network device will not work with ethtool.
Now that you know your device, lets have some fun, shall we? Note: Most linux kernels mark ethernet devices as ethX, where X is the # (starting at 0) of the physical Ethernet interface.
Driver Information and Statistics
I know I know, start with the least used things first. But hey, someone might find this useful, right? I've probably had to query driver information a dozen times in 10+ years when dealing with kernel level issues, but someone is bound to run across this at some point in their life, and let me tell you, it can be easier to just run a single command, than digging through lsmod and hoping that a module picked up the driver properly.
ethtool -i ethX
Example output:
driver: r8169 version: 2.3LK-NAPI firmware-version: bus-info:0000:02:00.0
Gathering statistics can also be useful for troubleshooting rx/tx issues with your network card. By running the following command you will get statistics about your network card.
ethtool -S ethX
NIC statistics:
tx_packets: 148683
rx_packets: 179489
tx_errors: 0
rx_errors: 0
rx_missed: 0
align_errors: 0
tx_single_collisions: 0
tx_multi_collisions: 0
unicast: 116884
broadcast: 25361
multicast: 61674
tx_aborted: 0
tx_underrun: 0
From here you can see a list of transmitted, received and errored packets. This can be useful during network troubleshooting, combined with other network utilities such as tcpdump.
Tracing your Card
I'm sure this has happened to many of you, as I know it has happened to me. Ever had a server with more than 2 network cards? Raise your hand. Ever had more than two? Ever had to trace what physical network card was recorded in linux as ethX? Sure, you could do it the hard way: grab the MAC address off of ifconfig, plug all the cables into a managed switch and then dump the tables on the switch to find what MAC address goes where. Or, follow the blinking lights with ethtool. This one little switch has saved my bacon countless times, especially when setting up firewall/router appliances.
ethtool -p ethX [N] *where [N] is Number of seconds to blink.
ethtool -p eth0 15 Blink ethernet device 0 for 15 seconds
Look there! Blinking lights at the back of your ethernet adaptor. No need to hunt and peck to figure out what eth0 and eth1 is on your physical adaptor. 'ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN.'
Testing your Ethernet Adapter
Now, this is one that I haven't had to use before, as it's been a rare day that an Ethernet adapter has gone out on me. But nonetheless, this is still a useful switch to have in the sys admin's bag of tricks. This will run some basic tests against your hardware ethernet interface. There are two options with this test, an online test (tests nvram and a link test) and an offline test (register, memory, loopback, interrupt). The offline test will more than likely boot your ethernet connection offline during testing, so be aware of this if you are running this against a production server or a machine that you only have remote access to.
ethtool -t ethX [offline|online]
*Note some Ethernet devices don't support online or offline test. During this
blog post I found 4 NIC's that didn't support testing, but a half dozen of
them that did.
The test result is PASS The test extra info: nvram test (online) 0 link test (online) 0 register test (offline) 0 memory test (offline) 0 loopback test (offline) 0 interrupt test (offline) 0Changing Ethernet Settings - If you run ethtool ethX without a switch, you will get the settings for your ethernet device as such:
Settings for eth0:
Supported ports: [ TP MII ]
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 pause frame use: No
Advertised auto-negotiation: Yes Link
partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 100Mb/s Duplex: Full
Port: MII
PHYAD:0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
Link detected: yes
This is a lot to process, but granted ethtool just prints it out line by line, sucking up as much space as it can. It can be summed up as such: Device supports TP and MII, up to 1000baseT/Full, Auto-Negotiation. Partner (Switch) support up to 100baseT/Full, and auto negotiation. Actual settings of device: 100Mb/s, Full Duplex, Running MII, Physical Address 0, Set to Auto negotiation, WoL is enabled and link is detected. Of course there are some more parts, but these are pretty much the juicy tidbits that you need to know.
When I have a device that is acting up, I tend to run: ethtool ethX, check the Supported link modes, the Link partner advertised link modes and the actual speed and Duplex. If my Supported link mode is set low (say 10/Half for some reason) but my switch supports 1000baseT/Full then I'll use ethtool -s ethX to change my ethernet settings to 1000baseT/Full. Just about anything you see from: ethtool ethX, can be changed with ethtool -S ethX. In this case you would use the following:
ethtool -S eth0 speed 1000 duplex full autoneg on
Note: I set autoneg on just in case. The device should have auto negotiated properly when powered up, but it didn't. So for my own sanity I tend to just set auto-negotiation on.
What you can also do with this switch is set Wake-On-Lan. I won't be getting into Wake-On-Lan today as I have heavily documented it in a personal blogpost located at www.jaysonbroughton.com.
Conclusion
I hope by know you have figured out that this is just a basic introduction to ethtool, and not a full course on ethernet standards, as I have left out some information and substituted what I felt was necessary information based on the years that I have been using ethernet utilities. There is so much more that you can use with ethtool, and combined with other such tools this can become one deadly tool in a sys admin's bag of tricks.
www.jaysonbroughton.com
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- RSS Feeds
- Trying to Tame the Tablet
- What's the tweeting protocol?
- Dart: a New Web Programming Experience
- Drupal is an Awesome CMS and a Crappy development framework
4 hours 10 min ago - IT industry leaders
6 hours 33 min ago - Reply to comment | Linux Journal
23 hours 21 min ago - Reply to comment | Linux Journal
1 day 1 hour ago - Reply to comment | Linux Journal
1 day 3 hours ago - great post
1 day 3 hours ago - Google Docs
1 day 4 hours ago - Reply to comment | Linux Journal
1 day 8 hours ago - Reply to comment | Linux Journal
1 day 9 hours ago - Web Hosting IQ
1 day 11 hours ago



Comments
user-defined commands using ethtool
Hi,
Is there a provision to send user-defined commands to the driver using ethtool? For example, if I don't want to use ioctl interface and I want to send a special command to the driver, how could I send it using ethtool?
Thanks,
-SS
set ethernet settings
Hi,
Good article. The last command didnt work on my ubuntu box, used ethtool -s instead and when I set speed to 1000 my network connection died. Guess the router doesnt support gigabit connections. Set it back and it worked fine. Thanks for the info.
Nice article.
Nice article.
parted
parted is an obscure name for a partition editor?
Nice article. Didn't know about "-p"
Didn't know about -p option. I'll try it on my servers. Thanks for the tip.
Hope it works because it failed in my home computer:
# ethtool -p eth0 15
Cannot identify NIC: Operation not supported
# ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version:
bus-info: 0000:04:00.0
Rafael Varela
http://webspersoais.usc.es/rafael.varela
http://minglanillosesferoides.blogspot.com
Yea, I noticed some of the
Yea, I noticed some of the machines at the house didn't work with the -p, but some did. I think it had to do with the type of NIC you have installed in your machine. Same thing with testing the nic as I outlined in the article, sometimes it worked and sometimes it didn't. But if you can get it to work at your job, that's a bonus :-) Nothing like having blinking lights to trace ethernet adapters.
Agreed
Yes, -p it's a great feature that I'd love to have it working in my servers.
Thanks for your article.
Rafael Varela
http://webspersoais.usc.es/rafael.varela
http://minglanillosesferoides.blogspot.com
Good Article
Very useful information.I learned new options from this post.Thank you.
The best part of this is that
The best part of this is that I was finally able to find in its entirety one of the funniest signs I have ever seen that was on one of my computer engineering teachers office wall due to a reference in this article...
Cool article!
This was a really nice piece. I learned of a new tool today, and specially the blinking bit :)
Thanks for this.
Your Welcome
Glad you enjoyed it :-)
Actually ethtool is not
Actually ethtool is not completely useless with bonded interfaces. It can, for example, tell you if the bonded interface link is up (i.e. at least on of the underlying physical links is up) or down (i.e. all the underlying physical links are down).
Bonded interfaces
That's true, you can use it to see bonded interface link. You can also use it to see what ethernet device (eth0 or eth1) is active on the bond with ethtool and what is on standby (with linkup as a response from ethtool). But as far as the utilities that I went over here, testing on bond0 was a no-go. Thanks for bringing that up though :-)
Gooooooood Article
Gooooooood Article
without further -adieu- ado
without further -adieu- ado
Yes, Ado. My bad ;-) My
Yes, Ado. My bad ;-) My better half is french, and our son is french. I just know I'm going to catch crap for putting Adieu in place of Ado. Silly me, thanks for bringing that one up
Ethtool
Good article - nice and clear and not too meaty. Thanks for the heads up - much appreciated
Ethtool
Good article - nice and clear and not too meaty. Thanks for the heads up - much appreciated
ipconfig is obsolete
On my Fedora system, man ifconfig says that ipconfig is obsolete and that one should use ip addr and ip link instead.
pcoq, yes you are correct.
pcoq,
yes you are correct. Man's been talking about ifconfig being obsolete since Kernel level 2.0 I believe (and I could be wrong about that as well). If for some reason the newer version of Fedora doesn't let you use ifconfig (should be ifconfig, not ipconfig). Then you can try: 'ip addr show' and that should list your ethernet interfaces.
kyle rankin
kyle rankin! HAHAHA!!!
http://filmsbykris.com/
Everything you ever need to know about Open-Source Software.
Correction
I believe that you meant for
"I hope by know you have..."
to be
"I hope by now you have..."
Yup, that is what it should
Yup, that is what it should have said. But the real question is, did you learn something about ethtool that you didn't know before? That's what I get for editing 3x and missing that one. Good eye! ;-)
It was honestly more of a
It was honestly more of a refresher for me, as I'm a Linux sysadmin/network admin professionally, but it is well written and should be very handy for those who are newer or don't usually have to deal with this stuff. I got here because saw the article in the LJ RSS feed and decided to check it out.
Believe me, I know how easy it can be to miss an error when you're proofing your own text. Your brain tends to read what you meant to type instead of what is actually there. Good job on the article :)
Intresting article! Btw: Your
Intresting article!
Btw:
Your comment system needs a way to report spam!
logged in users can report
logged in users can report spam.
Katherine Druckman is webmistress at LinuxJournal.com. You might find her on Twitter or at the Southwest Drupal Summit
This was awesome! Didn't know
This was awesome! Didn't know about this before.. now i do ;)
Good to hear! Glad you
Good to hear! Glad you learned something new about Linux :-)