查看linux系统下网卡是否连接网线的状态

一、通过mii-tool指令  mii-tool不支持1000Mbps以上网口
[root@linuxzgf ~]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: no link
[root@linuxzgf ~]#
       
      [root@linuxzgf ~]# mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:50:43, model 10 rev 2
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 100baseT4 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
eth1: no link
  product info: vendor 00:50:43, model 10 rev 2
  basic mode:   autonegotiation enabled
  basic status: no link
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
[root@linuxzgf ~]#
       
[root@linuxzgf ~]# mii-tool -w
14:52:45 eth0: negotiated 100baseTx-FD, link ok
14:52:45 eth1: no link
      //mii-tool主要是用于配置网卡工作模式的指令,同时也可以进行查询、监控等工作!

二、ethtool

[root@linuxzgf ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: yes
[root@linuxzgf ~]#

[root@linuxzgf ~]# ethtool eth1
Settings for eth1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: Unknown! (65535)
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: no
[root@linuxzgf ~]#

从上面可以看出eth0 处于连接状态,eth1没有连接
  
三、
[root@linuxzgf ~]# /etc/init.d/network status
配置设备:
lo eth0 eth0.10 eth0.2 eth0.3 eth0.4 eth0.5 eth0.7 eth0.8 eth1
当前的活跃设备:
lo eth0 eth0.10
[root@linuxzgf ~]#
    
等同于
     [root@linuxzgf root]# service --status-all
      ............
      ............
      Configured devices:
      lo eth0 eth1
      Currently active devices:
      lo eth0
      ............
      ............
四、ifconfig -a
    [root@linuxzgf ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:E0:81:80:D8:96 
          inet6 addr: fe80::2e0:81ff:fe80:d896/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:626032 errors:0 dropped:0 overruns:0 frame:0
          TX packets:415035 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:123631002 (117.9 MiB)  TX bytes:297575498 (283.7 MiB)
          Base address:0x2000 Memory:df300000-df320000

   eth1      Link encap:Ethernet  HWaddr 00:E0:81:80:D8:97 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Base address:0x2020 Memory:df320000-df340000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:147 errors:0 dropped:0 overruns:0 frame:0
          TX packets:147 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:27895 (27.2 KiB)  TX bytes:27895 (27.2 KiB)

五、lspci也可以看到网卡的信息

你可能感兴趣的:(linux,status,product,enabled,negotiated)