Wednesday, July 28, 2010

Linux: How to tell if you are Link UP

I was reviewing some of the most common interview questions asked to Linux Systems Administrators. I saw a great one:

Q. "How can you tell if an interface is link up?"

A. I guessed the old fashion one:
$>ifconfig eth0


Alternative answers:
$>ethtool eth0
Settings for eth0:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full

Port: MII
PHYAD: 1
Transceiver: external
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes

*Interesting enough ethtool provides us some more key info see color code below for more details:
Current Duplex rate of device: [#]
Current Speed of device: [#]


$>ip link show
1: lo: loopback,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link>loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: broadcast,multicast,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link>ether 00:1e:8c:6e:e0:4f brd ff:ff:ff:ff:ff:ff
4: vboxnet0: broadcast,multicast\>mtu 1500 qdisc noop state DOWN qlen 1000
link>ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff

$> dmesg grep eth
[ 0.238932] ACPI Error (psparse-0537): Method parse/execution failed [\_SB_.MEM_._CRS] (Node f7019b70), AE_AML_BUFFER_LIMIT
[ 0.238957] ACPI Error (uteval-0256): Method execution failed [\_SB_.MEM_._CRS] (Node f7019b70), AE_AML_BUFFER_LIMIT
[ 2.230873] forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
[ 2.231181] forcedeth 0000:00:07.0: PCI INT A -> Link[APCH] -> GSI 23 (level, low) -> IRQ 23
[ 2.231185] forcedeth 0000:00:07.0: setting latency timer to 64
[ 2.748879] forcedeth 0000:00:07.0: ifname eth0, PHY OUI 0x732 @ 1, addr 00:1e:8c:6e:e0:4f
[ 2.748883] forcedeth 0000:00:07.0: highdma pwrctl mgmt lnktim msi desc-v3
[ 13.217598] forcedeth 0000:00:07.0: irq 26 for MSI/MSI-X
[ 805.825023] device eth0 entered promiscuous mode

**** Note this last case will tell you if link fluxes happen.

No comments: