How to check network interface link state in Linux

A Linux host can have a configured address and still fail at the link layer when a cable, switch port, virtual peer, or driver carrier is down. Checking interface link state first separates a local Layer 2 problem from routing, DNS, firewall, or application failures.

The ip command reports two different signals in the same view. The UP flag shows the interface is administratively enabled, while LOWER_UP and the operational state show whether the lower layer has carrier and can pass traffic. Loopback often reports UNKNOWN because it does not depend on a physical carrier.

The kernel also exposes operstate and carrier under /sys/class/net/<iface>/. A carrier value of 1 confirms the lower layer is up, while 0 or a missing LOWER_UP flag points to a disconnected cable, down switch port, failed virtual peer, or driver/device condition. Stacked devices such as VLAN, bond, bridge, and veth may need checking at both the logical interface and its lower device.

  1. List interface link states.
    $ ip -br link
    lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
    eth0             UP             52:54:00:12:34:56 <BROADCAST,MULTICAST,UP,LOWER_UP>
    enp2s0           DOWN           52:54:00:12:34:57 <NO-CARRIER,BROADCAST,MULTICAST,UP>

    UP in the state column means the interface is operationally usable. DOWN with NO-CARRIER means the interface is enabled but does not see carrier.

  2. Inspect the target interface flags.
    $ ip link show dev eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
        link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff

    LOWER_UP is the carrier signal. If UP is missing from the flags, the interface is administratively down and must be enabled before carrier is meaningful.

  3. Read the operational state from sysfs.
    $ cat /sys/class/net/eth0/operstate
    up

    Expected values include up, down, lowerlayerdown, dormant, and unknown. UNKNOWN is common for lo and some drivers that do not report a full operational state.

  4. Read the carrier bit from sysfs.
    $ cat /sys/class/net/eth0/carrier
    1

    Value 1 means carrier is detected. Value 0 means the lower layer is down for that interface.

  5. Check address assignment only after carrier is present.
    $ ip -br address show dev eth0
    eth0             UP             192.0.2.40/24 fe80::5054:ff:fe12:3456/64

    An interface can have carrier and still lack an address because of static configuration or DHCP failure.
    Related: How to show IP addresses in Linux