Monday, May 27, 2013

How to check the network cable is connected/patched in Linux

You can test  Link by it by running mii-tool

Example

# mii-tool
eth0: negotiated 100baseTx-FD flow-control, link ok
eth1: autonegotiation restarted, no link
eth2: autonegotiation restarted, no link
eth3: autonegotiation restarted, no link

How to check the network cable is connected or not in the linux

for cable in `ls /sys/class/net | grep ^eth`; do  printf "$cable: "; cat /sys/class/net/$cable/carrier; done

if 0(blank)   = it would mean cables not connected or unplugged
if 1 = cable   connected, plugged

more eth0/flags; more eth1/flags;  more eth2/flags ; more eth3/flags
0x1003  << connected
0x1002
0x1002
0x1002

No comments:

Post a Comment