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

后端 未结 15 1398
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 04:23

In a Linux environment, I need to detect the physical connected or disconnected state of an RJ45 connector to its socket. Preferably using BASH scripting only.

The

15条回答
  •  鱼传尺愫
    2020-12-04 05:09

    on arch linux. (im not sure on other distros) you can view the operstate. which shows up if connected or down if not the operstate lives on

    /sys/class/net/(interface name here)/operstate
    #you can also put watch 
    watch -d -n -1 /sys/class/net/(interface name here)/operstate
    

提交回复
热议问题