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

后端 未结 15 1406
隐瞒了意图╮
隐瞒了意图╮ 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:26

    You can use ifconfig.

    # ifconfig eth0 up
    # ifconfig eth0
    

    If the entry shows RUNNING, the interface is physically connected. This will be shown regardless if the interface is configured.

    This is just another way to get the information in /sys/class/net/eth0/operstate.

提交回复
热议问题