Server has multiple NICs, only one of which has cable plugged in.
How can I test whether given port
ethX is plugged in or not ?
I found many similar questions, but neither
cat /sys/class/net/eth1/carrier works for me.
In my case, the cable is actually connected in
ethtool still shows
Link detected: no
Settings for eth2: Supported ports: [ FIBRE ] Supported link modes: 10000baseT/Full Supported pause frame use: Symmetric Supports auto-negotiation: No Advertised link modes: 10000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: No Speed: Unknown! Duplex: Unknown! (255) Port: Direct Attach Copper PHYAD: 0 Transceiver: internal Auto-negotiation: off Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: no
There is no cable connected in
ethtool output looks almost the same:
diff <(ethtool eth2) <(ethtool eth3) 1c1 < Settings for eth2: --- > Settings for eth3: 11c11 < Port: Direct Attach Copper --- > Port: Other
First when I bring the interface
eth2 up, then
Link detected: yes. After that,
ethtool reports the link as
yes, even when I ifdown the interface.
ethtool does not seem to work first time, before interface has been ifuped.
How can I reliably test whether given interface has cable plugged in or not ?