How to detect the physical connected state of a network cable/connector?


grep '' /sys/class/net/eth*/carrier /sys/class/net/eth*/operstate

According to my experience with Debian 6.* (and kernel v2.6.32-5) the carrier is 1 if the cable is connected and there's a signal, and it's 0 otherwise (or access to the carrier gives an Invalid argument error).

The operstate is up or down according to whether the interface is brought up or not.