-->
🏠 🔍
SHAREOLITE

linux ethtool command line example to find LAN connection status

Linux ethtool command line utility is very useful to collect information and status of network ports and physical link connectivity.

Below is an example on how to use ethtool to check whether a physical link is up or down. The interface name is passed as argument to the ethtool

linux ethtool command line example to find LAN connection status

 

Interface name of a network port , may be displayed using the command ifconfig as below

$ ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 170.0.2.151  netmask 255.255.248.0  broadcast 170.0.2.255
        inet6 fe80::b1ba:7d9e:2da:2478  prefixlen 64  scopeid 0x20<link>
        ether 98:be:94:22:dd:da  txqueuelen 1000  (Ethernet)
        RX packets 10691  bytes 944151 (922.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1445  bytes 287378 (280.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xbc580000-bc59ffff

Notice the highlighted interface name eno1 which is the first network port.

Now using ethtool , status of link may be displayed as below

# ethtool eno1
Settings for eno1
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off (auto)
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: no

Notice from above highlighted display , "Link detected" has a value "no" which indicates the physical link is down . 

Now after connecting the physical link to the network port , on re-executing the command status is displayed as below

# ethtool eno1
Settings for eno1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Full
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes

Notice the change in value of Link detected from "no" to "yes" and the connectivity speed.  

Hope this helps to few who are in search of a utility to debug LAN connection status.


Comments

–>