Sie sind auf Seite 1von 12

11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Home
Free eBook
Contact
About
Start Here

9 Linux ethtool Examples to Manipulate


Ethernet Card (NIC Card)
by Balakrishnan Mariyappan on October 28, 2010

12 Like 17 Tweet 18

Ethtool utility is used to view and change the ethernet device


parameters.

1. List Ethernet Device Properties

When you execute ethtool command with a device name, it displays the following information about the
ethernet device.

# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full

http://www.thegeekstuff.com/2010/10/ethtool-command/ 1/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: d
Wake-on: d
Link detected: yes

This above ethtool output displays ethernet card properties such as speed, wake on, duplex and the link
detection status. Following are the three types of duplexes available.

Full duplex : Enables sending and receiving of packets at the same time. This mode is used when
the ethernet device is connected to a switch.
Half duplex : Enables either sending or receiving of packets at a single point of time. This mode is
used when the ethernet device is connected to a hub.
Auto-negotiation : If enabled, the ethernet device itself decides whether to use either full duplex or
half duplex based on the network the ethernet device attached to.

2. Change NIC Parameter Using ethtool Option -s autoneg

The above ethtool eth0 output displays that the “Auto-negotiation” parameter is in enabled state. You can
disable this using autoneg option in the ethtool as shown below.

# ifdown eth0
eth0 device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
eth0 configuration: eth-bus-pci-0000:0b:00.0

# ethtool -s eth0 autoneg off

# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised auto-negotiation: No
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g

http://www.thegeekstuff.com/2010/10/ethtool-command/ 2/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Wake-on: g
Link detected: no
# ifup eth0

After the above change, you could see that the “link detection” value changed to down and auto-
negotiation is in off state.

3. Change the Speed of Ethernet Device

Using ethtool you can change the speed of the ethernet device to work with the certain network devices,
and the newly assign speed value should be within the limited capacity.

# ethtool -s eth0 speed 100 autoneg off

# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised auto-negotiation: No
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: g
Link detected: no

Once you change the speed when the adapter is online, it automatically goes offline, and you need to
bring it back online using ifup command.

Fab HomeFab Home


Taupo Right Side L Shape Sofa Carbon
GrayShop Now!-30%Rs. 34,999Rs.

49,999 Fab HomeFab


Home Kelvin Modular L Shape Sofa
Teal BlueShop Now!-38%Rs. 55,999Rs.

# ifup eth0
eth0 device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
eth0 configuration: eth-bus-pci-0000:0b:00.0

http://www.thegeekstuff.com/2010/10/ethtool-command/ 3/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Checking for network time protocol daemon (NTPD): running

# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: g
Link detected: yes

As shown in the above output, the speed changed from 1000Mb/s to 100Mb/s and auto-negotiation
parameter is unset.

To change the Maximum Transmission Unit (MTU), refer to our ifconfig examples article.

4. Display Ethernet Driver Settings

ethtool -i option displays driver version, firmware version and bus details as shown below.

# ethtool -i eth0
driver: bnx2
version: 2.0.1-suse
firmware-version: 1.9.3
bus-info: 0000:04:00.0

5. Display Auto-negotiation, RX and TX of eth0

View the autonegotiation details about the specific ethernet device as shown below.

# ethtool -a eth0
Pause parameters for eth0:
Autonegotiate: on
RX: on
TX: on

6. Display Network Statistics of Specific Ethernet Device

Use ethtool -S option to display the bytes transfered, received, errors, etc, as shown below.

# ethtool -S eth0
NIC statistics:
rx_bytes: 74356477841
rx_error_bytes: 0
http://www.thegeekstuff.com/2010/10/ethtool-command/ 4/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

tx_bytes: 110725861146
tx_error_bytes: 0
rx_ucast_packets: 104169941
rx_mcast_packets: 138831
rx_bcast_packets: 59543904
tx_ucast_packets: 118118510
tx_mcast_packets: 10137453
tx_bcast_packets: 2221841
tx_mac_errors: 0
tx_carrier_errors: 0
rx_crc_errors: 0
rx_align_errors: 0
tx_single_collisions: 0
tx_multi_collisions: 0
tx_deferred: 0
tx_excess_collisions: 0
tx_late_collisions: 0
tx_total_collisions: 0
rx_fragments: 0
rx_jabbers: 0
rx_undersize_packets: 0
rx_oversize_packets: 0
rx_64_byte_packets: 61154057
rx_65_to_127_byte_packets: 55038726
rx_128_to_255_byte_packets: 426962
rx_256_to_511_byte_packets: 3573763
rx_512_to_1023_byte_packets: 893173
rx_1024_to_1522_byte_packets: 42765995
rx_1523_to_9022_byte_packets: 0
tx_64_byte_packets: 3633165
tx_65_to_127_byte_packets: 51169838
tx_128_to_255_byte_packets: 3812067
tx_256_to_511_byte_packets: 113766
tx_512_to_1023_byte_packets: 104081
tx_1024_to_1522_byte_packets: 71644887
tx_1523_to_9022_byte_packets: 0
rx_xon_frames: 0
rx_xoff_frames: 0
tx_xon_frames: 0
tx_xoff_frames: 0
rx_mac_ctrl_frames: 0
rx_filtered_packets: 14596600
rx_discards: 0
rx_fw_discards: 0

7. Troubleshoot the Ethernet Connection Issues

When there is a problem with the network connection, you might want to check (or change) the ethernet
device parameters explained in the above examples, when you see following issues in the output of
ethtool command.

Speed and Duplex value is shown as Unknown


Link detection value is shown as No

Upon successful connection, the three parameters mentioned above gets appropriate values. i.e Speed is
http://www.thegeekstuff.com/2010/10/ethtool-command/ 5/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

assigned with known value, Duplex become either Full/Half, and the Link detection becomes Yes.

After the above changes, if the Link Detection still says “No”, check whether there are any issues in the
cables that runs from the switch and the system, you might want to dig into that aspect further.

To capture and analyze packets from a specific network interface, use tcpdump utility.

8. Identify Specific Device From Multiple Devices (Blink LED Port of NIC Card)

Let us assume that you have a machine with four ethernet adapters, and you want to identify the physical
port of a particular ethernet card. (For example, eth0).

Use ethtool option -p, which will make the corresponding LED of physical port to blink.

# ethtool -p eth0

9. Make Changes Permanent After Reboot

If you’ve changed any ethernet device parameters using the ethtool, it will all disappear after the next
reboot, unless you do the following.

On ubuntu, you have to modify /etc/network/interfaces file and add all your changes as shown below.

# vim /etc/network/interfaces
post-up ethtool -s eth2 speed 1000 duplex full autoneg off

The above line should be the last line of the file. This will change speed, duplex and autoneg of eth2
device permanently.

On SUSE, modify the /etc/sysconfig/network/ifcfg-eth-id file and include a new script using
POST_UP_SCRIPT variable as shown below. Include the below line as the last line in the corresponding
eth1 adpater config file.

# vim /etc/sysconfig/network/ifcfg-eth-id
POST_UP_SCRIPT='eth1'

Then, create a new file scripts/eth1 as shown below under /etc/sysconfig/network directory. Make sure
that the script has execute permission and ensure that the ethtool utility is present under /sbin directory.

# cd /etc/sysconfig/network/

# vim scripts/eth1
#!/bin/bash
/sbin/ethtool -s duplex full speed 100 autoneg off

12 Tweet 18 Like 17 > Add your comment

http://www.thegeekstuff.com/2010/10/ethtool-command/ 6/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Linux provides several powerful administrative tools and utilities which


will help you to manage your systems effectively. If you don’t know what these tools are and how to use
them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus
of this course is to help you understand system administration tools, which will help you to become an
effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

1. 50 Linux Sysadmin Tutorials Awk Introduction – 7 Awk Print


2. 50 Most Frequently Used Linux Commands Examples
(With Examples) Advanced Sed Substitution Examples
3. Top 25 Best Linux Performance Monitoring and 8 Essential Vim Editor Navigation
Debugging Tools Fundamentals
4. Mommy, I found it! – 15 Practical Linux Find 25 Most Frequently Used Linux IPTables
Command Examples Rules Examples
5. Linux 101 Hacks 2nd Edition eBook Turbocharge PuTTY with 12 Powerful
Add-Ons

{ 10 comments… read them below or add one }

1 Ritesh Yeole October 28, 2010 at 3:00 am

Its awesome!!!

I have a problem regarding the ethernet card.

http://www.thegeekstuff.com/2010/10/ethtool-command/ 7/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Problem: On board ethernet card is not detected on Centos 5 /Fedora 8 sometimes.


It gives the error as elying initialising, eth does not seem to present.

Can you tell me what is the solution on this ?

Thanks,
Ritesh

2 Tapas Mallick October 28, 2010 at 6:58 am

Is it possible to clear the Statistics collected from “ethtool -S ethX” without rebooting the Host ?

3 Kirill October 28, 2010 at 12:35 pm

Change MAC-address http://embedded.seattle.intel-research.net/wiki/index.php?


title=Setting_the_MAC_Address_from_Linux

4 brad October 28, 2010 at 12:46 pm

On SuSE, you can add ethtool commands directly to the “ifcfg-ethX” file.
For example, edit:
/etc/sysconfig/network/ifcfg-eth0
and add:
ETHTOOL_OPTIONS=’speed 100 duplex full autoneg off’
Usually, the variable exist but is blank:
ETHTOOL_OPTIONS=”

bb

5 hulk October 28, 2010 at 5:04 pm

Number 10 should be turning on WOL.

#ethtool eth0 wol g

6 Nux November 1, 2010 at 10:33 pm

“post-up ethtool -s eth2 speed 1000 duplex full autoneg off” <- this is incorrect.
AFAIK, autonegotiation is a required part of the standard for GigE 1000 Base-T (or so says the
IEEE standard).

7 sunny November 27, 2010 at 3:50 am

i have a problem in wake on lan . i can`t change the port of the wake on lan so please give me
solution

8 Sergio January 3, 2011 at 7:19 am

I tried out the ‘-p’ option in my laptop (just one Ethernet ) and my system crashed totally but the
LED was blinking after all. I have to try it out on different systems.

http://www.thegeekstuff.com/2010/10/ethtool-command/ 8/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Congratulations

9 suryaprathap December 4, 2013 at 6:51 am

Hi Balakrishnan,
what is meant by PHYAD ,MDI-X ,Wake-on :d

10 Sandy6933 October 21, 2014 at 8:52 pm

Thank you!

Leave a Comment

Name

E-mail

Website

Notify me of followup comments via e-mail

Submit

Previous post: 5 Best Point and Shoot Digital Cameras

Next post: Build a Good Habit in 30 Days

RSS | Email | Twitter | Facebook | Google+

Search

http://www.thegeekstuff.com/2010/10/ethtool-command/ 9/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

-69% -69%

Zovi Black And Grey Zovi Grey Zipper


Suede Shoes Portable Shoes

COURSE

Linux Sysadmin CentOS 6 Course - Master the Tools, Configure it Right, and be Lazy

EBOOKS

Linux 101 Hacks 2nd Edition eBook - Practical Examples to Build a Strong
Foundation in Linux
Bash 101 Hacks eBook - Take Control of Your Bash Command Line and Shell Scripting
Sed and Awk 101 Hacks eBook - Enhance Your UNIX / Linux Life with Sed and Awk
Vim 101 Hacks eBook - Practical Examples for Becoming Fast and Productive in Vim Editor
Nagios Core 3 eBook - Monitor Everything, Be Proactive, and Sleep Well
The Geek Stuff
Like

8,551 people like The Geek Stuff.

Facebook social plugin

POPULAR POSTS

12 Amazing and Essential Linux Books To Enrich Your Brain and Library
50 UNIX / Linux Sysadmin Tutorials
50 Most Frequently Used UNIX / Linux Commands (With Examples)
How To Be Productive and Get Things Done Using GTD
30 Things To Do When you are Bored and have a Computer
Linux Directory Structure (File System Structure) Explained with Examples
http://www.thegeekstuff.com/2010/10/ethtool-command/ 10/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

Linux Crontab: 15 Awesome Cron Job Examples


Get a Grip on the Grep! – 15 Practical Grep Command Examples
Unix LS Command: 15 Practical Examples
15 Examples To Master Linux Command Line History
Top 10 Open Source Bug Tracking System
Vi and Vim Macro Tutorial: How To Record and Play
Mommy, I found it! -- 15 Practical Linux Find Command Examples
15 Awesome Gmail Tips and Tricks
15 Awesome Google Search Tips and Tricks
RAID 0, RAID 1, RAID 5, RAID 10 Explained with Diagrams
Can You Top This? 15 Practical Linux Top Command Examples
Top 5 Best System Monitoring Tools
Top 5 Best Linux OS Distributions
How To Monitor Remote Linux Host using Nagios 3.0
Awk Introduction Tutorial – 7 Awk Print Examples
How to Backup Linux? 15 rsync Command Examples
The Ultimate Wget Download Guide With 15 Awesome Examples
Top 5 Best Linux Text Editors
Packet Analyzer: 15 TCPDUMP Command Examples
The Ultimate Bash Array Tutorial with 15 Examples
3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
Unix Sed Tutorial: Advanced Sed Substitution Examples
UNIX / Linux: 10 Netstat Command Examples
The Ultimate Guide for Creating Strong Passwords
6 Steps to Secure Your Home Wireless Network
Turbocharge PuTTY with 12 Powerful Add-Ons

CATEGORIES

Linux Tutorials
Vim Editor
Sed Scripting
Awk Scripting
Bash Shell Scripting
Nagios Monitoring
OpenSSH
IPTables Firewall
Apache Web Server
MySQL Database
Perl Programming
Google Tutorials
Ubuntu Tutorials
PostgreSQL DB
Hello World Examples
C Programming
C++ Programming
DELL Server Tutorials
Oracle Database
http://www.thegeekstuff.com/2010/10/ethtool-command/ 11/12
11/18/2014 9 Linux ethtool Examples to Manipulate Ethernet Card (NIC Card)

VMware Tutorials
Ramesh Natarajan

Follow

About The Geek Stuff

My name is Ramesh Natarajan. I will be posting instruction guides, how-to,


troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to
write articles that will either teach you or help you resolve a problem. Read more about Ramesh
Natarajan and the blog.

Support Us

Support this blog by purchasing one of my ebooks.

Bash 101 Hacks eBook

Sed and Awk 101 Hacks eBook

Vim 101 Hacks eBook

Nagios Core 3 eBook

Contact Us

Email Me : Use this Contact Form to get in touch me with your comments, questions or
suggestions about this site. You can also simply drop me a line to say hello!.

Follow us on Google+

Follow us on Twitter

Become a fan on Facebook

Copyright © 2008–2014 Ramesh Natarajan. All rights reserved | Terms of Service

http://www.thegeekstuff.com/2010/10/ethtool-command/ 12/12

Das könnte Ihnen auch gefallen