通过ifconfig和ethtool获取网卡相关信息

ifconfig

[root@mio-254 ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 74:D4:35:E0:32:87  
          inet addr:192.168.1.254  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::76d4:35ff:fee0:3287/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:555722 errors:0 dropped:0 overruns:0 frame:0
          TX packets:122601 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:374032143 (356.7 MiB)  TX bytes:22318398 (21.2 MiB)

结果中展示了服务器的网卡数目,IP地址,MAC地址,MTU大小,网卡收发包情况(包括丢包和错误包等),这些都是服务器排除故障时,首先要检查的数据

ethtool

与网卡有关的另一个重要命令是ethtool,通过该命令可以监测网卡速度及工作模式

[root@mio-254 ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        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 
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                             100baseT/Half 100baseT/Full 
        Link partner advertised pause frame use: Symmetric
        Link partner advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes
[root@mio-254 ~]#