zoukankan      html  css  js  c++  java
  • centos 网卡状态

    由于ifconfig命令没法看到网卡的一些状态, 以下有5种方法查看网卡状态,是否连通网线

    1)# dmesg | grep eth
    .....
    e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
    e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

    2)# mii-tool
    eth0: negotiated 100baseTx-FD, link ok
    eth1: negotiated 100baseTx-FD, link ok

    3)# ethtool eth0 | grep Link
    Link detected: yes

    4)# cat /sys/class/net/eth0/operstate
    up

    5)# ip link show
    2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:e4 brd ff:ff:ff:ff:ff:ff
    3: eth1: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:ee brd ff:ff:ff:ff:ff:ff

    ----------------------------------------------------------------------------

    ifconfig -a

    使用ifconfig 命令可以获取所有网卡设备的信息,如果需要查看哪些设备连接网线,需要通过 RX packets或者TX packets进行判断,如果数值为0的话通常表示没有硬件连接。

    缺点:
    不能直接显示设备连接情况,需要通过其它参数进行判断。如果网口连接过网线,可能会导致数据不准确,需要使用ifdown、ifup命令重启设备。
    ip a

    使用这个命令可以获取本机上所有设备的状态信息, 通过 “qdisc mq state”后面的值是UP还是DOWN来判断是否已经连接网线。
    (此命令对于网线,光纤,InfiniBand类型设备都可以进行支持)
    nmcli dev status

    使用这个命令可以获取本机上所有设备的状态信息, 通过CONNECTIONZ字段就可以很方便看出是否有设备连接。
    推荐的使用方式!

    此外,还可以使用service network status 命令查看当前配置的网卡设备信息。

  • 相关阅读:
    gitio博客搭建,hexo + NeXT
    [MIsc]JD笔试编程题
    [MATH]Big Integer +
    【Math】GCD XOR 证明
    【Math】最近点对
    【SRM】600#div2 B 枚举
    【Game】组合游戏
    【Game】找出游戏必胜态
    【DP】树形DP 记忆化搜索
    141. Linked List Cycle
  • 原文地址:https://www.cnblogs.com/leon-ytparty/p/10652916.html
Copyright © 2011-2022 走看看