https://access.redhat.com/solutions/1465433
How to find out if the ethernet cable is plugged into the physical interface without bringing up an interface?
SOLUTION 已验证 - 已更新 2015年十一月26日17:18 -
环境
- Red Hat Enterprise Linux
- 6.x
问题
- How to check if the
ethernet
cable is plugged into the physical interface without bringing up an interface?
决议
- For checking the status of the
ethernet
cable useip link
command.
1) If the ethernet
cable is connected, and it is up also then it will show in the ip link
command. Check the output of eth0.
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 5000
link/ether 00:16:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
In this case, eth0 <BROADCAST,MULTICAST,UP,LOWER_UP> is connected , and the status of the ethernet
cable is also Up "state UP qlen 5000".
2) If ethernet
cable is connected, but it is down then check below output:
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 5000
link/ether 00:16:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
In this case, eth0 <NO-CARRIER,BROADCAST,MULTICAST,UP> is connected, but the status of the ethernet
cable is down.
3) If ethernet
cable is not connected,then check below output:
In this nothing will come.
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff