Linux识别是否插入网线命令获取网线插入状态
1、检查sys系统文件
cat /sys/class/net/eth0/carrier #0代表未插入网线,1代表插入网线
2、ifconfig检索RUNNING字段
如下结果,UP BROADCAST RUNNING MULTICAST其中的RUNNING代表已插入网线
z@zlf:/sys/class/net/ens33$ ifconfig ens33 Link encap:Ethernet HWaddr 00:0c:29:b8:dd:d3 inet addr:192.168.5.87 Bcast:192.168.5.255 Mask:255.255.255.0 inet6 addr: fe80::a7a1:7023:d4f6:21a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2184341 errors:0 dropped:5654 overruns:0 frame:0 TX packets:2041258 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:391099791 (391.0 MB) TX bytes:1683781935 (1.6 GB)
3、ethtool检查link detected字段
z@zlf:/sys/class/net/ens33$ ethtool ens33 Settings for ens33: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Cannot get wake-on-lan settings: Operation not permitted Current message level: 0x00000007 (7) drv probe link Link detected: yes
可以看到最后一行是link detected为yes
相关推荐
cpu单核负载导致5G跑不满,mt7621+mt715 5G wifi吞吐量低
openwrt固件生成ipk的过程ipk是如何生成的?ipk文件本质是什么?
OPENWRT卸载NTFS使用ntfs-3g挂载NTFS硬盘支持读写NTFS硬盘
点击链接加入群聊三群:751529538
点击链接加入群聊二群:376877156
点击链接加入群聊【路由器交流群:622891808已满】
本站附件分享,如果附件失效,可以去找找看
饿了么红包
于2022-11-11发布