• Linux下如何通过命令检查网卡是否插上网线


    How To:Linux下如何通过命令检查网卡是否插上网线

     

    主要工具为ethtool来检查,主要关注的字段为"Link detected",注意如下的输出,其中em4实际物理上并未插上网线,而em1是插上网线的:

    复制代码
    # ethtool em4
    Settings for em4:
            Supported ports: [ TP ]
            Supported link modes:   10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Supported pause frame use: No
            Supports auto-negotiation: Yes
            Advertised link modes:  10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Advertised pause frame use: Symmetric
            Advertised auto-negotiation: Yes
            Speed: Unknown!
            Duplex: Unknown! (255)
            Port: Twisted Pair
            PHYAD: 2
            Transceiver: internal
            Auto-negotiation: on
            MDI-X: Unknown
            Supports Wake-on: g
            Wake-on: d
            Current message level: 0x000000ff (255)
                                   drv probe link timer ifdown ifup rx_err tx_err
            Link detected: no
    # ethtool em1
    Settings for em1:
            Supported ports: [ TP ]
            Supported link modes:   10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Supported pause frame use: No
            Supports auto-negotiation: Yes
            Advertised link modes:  10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
                                    1000baseT/Half 1000baseT/Full 
            Advertised pause frame use: Symmetric
            Advertised auto-negotiation: Yes
            Link partner advertised link modes:  100baseT/Full 
                                                 1000baseT/Full 
            Link partner advertised pause frame use: Transmit-only
            Link partner advertised auto-negotiation: Yes
            Speed: 1000Mb/s
            Duplex: Full
            Port: Twisted Pair
            PHYAD: 1
            Transceiver: internal
            Auto-negotiation: on
            MDI-X: on
            Supports Wake-on: g
            Wake-on: d
            Current message level: 0x000000ff (255)
                                   drv probe link timer ifdown ifup rx_err tx_err
            Link detected: yes

    此外,还可以ifconfig 命令:
    1.  

      然后让我们模拟一下环境:拔掉eth1的网线,再次执行:ifconfig -a这条命令,对比一下eth0和eth1的区别,发现eht1不再running。没错这个字段就是看网卡是否有连线的,或者网线是否有问题的。

      linux查看网卡是否连接网线
    2.  

      接着让我们把eth1的网线插上,再执行一遍:ifconfig -a;对比一下eth0和eth1,发现此时eth1已经running了。

      linux查看网卡是否连接网线 


  • 相关阅读:
    android操作数据库
    Android读写SD卡上的文件
    第四章 函数与程序结构
    getchar()与EOF
    NULL, '',0 '0'的区别
    TCPL 行计数
    行计数
    getchar()用法
    在C语言中,double、long、unsigned、int、char类型数据所占字节数
    队列——解密QQ号
  • 原文地址:https://www.cnblogs.com/as007012/p/10020062.html
Copyright © 2020-2023  润新知