1) 通过mii-tool指令
       [root@localhost root]# mii-tool
        eth0: negotiated 100baseTx-FD, link ok
        eth1: no link
       或
       [root@localhost root]# mii-tool -v
        eth0: negotiated 100baseTx-FD, link ok
          product info: vendor 00:50:43, model 2 rev 3
          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: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
        eth1: no link
          product info: vendor 00:50:43, model 2 rev 3
          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@localhost root]# mii-tool -w
       21:20:33 eth0: negotiated 100baseTx-FD, link ok
       21:20:33 eth1: no link

//mii-tool主要是用于配置网卡工作模式的指令,同时也可以进行查询、监控等工作!

2) 
     [root@localhost /]# /etc/init.d/network status
      Configured devices:
      lo eth0 eth1
      Currently active devices:
      lo eth0
     等同于
     [root@localhost root]# service --status-all
      ............
      ............

Configured devices:
      lo eth0 eth1
      Currently active devices:
      lo eth0
      ............
      ............
   3)ifconfig -a
    [root@localhost /]# ifconfig -a
    eth0 Link encap:Ethernet HWaddr 00:09:6B:09:08:FC 
          inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
          inet6 addr: fe80::209:6bff:fe09:8fc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:106732953 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:104379788 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:2351331877 (2.1 GiB) TX bytes:391707945 (373.5 MiB)
          Base address:0x2500 Memory:fbfe0000-fc000000 
   eth1   Link encap:Ethernet HWaddr 00:09:6B:09:08:FD 
          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:0x2540 Memory:fbfc0000-fbfe0000

4)ethtool

ethtool eth0
Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes: 10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x000000ff (255)
        Link detected: yes

ethtool eth1

Settings for eth1:

Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes: 10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Half 1000baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: Unknown! (0)
        Duplex: Half
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x000000ff (255)
        Link detected: no
从上面可以看出eth0 处于连接状态,eth1没有连接

二. 查看网卡的配置

一般在linux下查看网络配置可以使用ifconfig命令,可以显示当前网卡的基本配置信息。

终端输入ifconfig 会出现一下内容:

eth0
Link encap:Ethernet HWaddr 00:0C:29:0C:4B:0F
inet addr:192.168.37.128 Bcast:192.168.37.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame.:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2823 (2.7 Kb)
TX bytes:2722 (2.6 Kb)
Interrupt:10 Base address:0x1080
他们分别表示:
Eth0:网络接口
link encap:网络类型
HWaddr:网卡物理地址
Inet addr :IP地址
Bcast:广播地址
Mask:子网掩码
UP:正在使用的网络接口

RX packets,TX packets接收和传输的数据包个数
RX byte,TX byte表示接搜和传输的具体数目
Interrupt:终端信息
Base address:内存地址

三. 网卡配置文件

如果希望每次启动linux时,都能为你的网卡配置正确的网络地址,可以采用下列两种方法:

1. 每次开机后,使用ifconfig手动重新设置网卡的配置;

2. 在开机流程中,将网络配置的设置保存在某些RC Script中。

第一种方式麻烦,第二种方式涉及到在哪个RC Script中配置网卡是比较适当的?

Linux启动过程中会执行以下三个RC Script。

1. /etc/rc.d/init.d/rc.sysinit;

2. /etc/rc.d/init.d/rc;

3. /etc/rc.d/init.d/rc.local

为了维护Linux的稳定性,建议不要修改前两项。但是,用ifconfig配置第三个RC Script的话,导致严重的问题:由于最后执行这个程序,在其执行之前,可能已经执行了数十项网络服务。因此,会造成一堆网络服务因为网卡尚未启动而无法顺利的启动。

四、网卡配置文件

解决上述问题的方法:每一个网络介质都对应一个配置文件,超级用户可以通过这些配置文件来配置网卡。

网卡配置文件存放在 /etc/sysconfig/network-scripts/目录中;

/etc/sysconfig/network-scripts/ifcfg-interface-name
   
    设置文件ifcfg-interface-name包含了初始化接口所需的大部分周详信息。其中interface-name将根据网卡的类型和排序而不 同,一般其名字为eth0、eth1、ppp0等,其中eth表示以太(eth0)类型网卡,0表示第一块网卡,1表示第二块网卡,而ppp0则表示第一 个point-to-poirt protocol网络接口。在ifcfg文件中定义的各项目取决于接口类型。
下面的值较问常见:
》DEVICE=name ,其中,name是物理设备名。
》IPADDR=addr,其中,addr是IP地址。
》NETMASK=mask,其中,mask是网络掩码值。
》NETWORK=addr,其中addr是网络地址。
》BROADCAST=addr,其中,addr是广播地址。
》GATEWAY=addr,其中addr是网关地址。
》ONBOOT=answer,其中,answer是yes(引导时激活设备)或no(引导时不激活设备)
》USERCTL=answer,其中,answer是yes(非root用户能控制该设备)或no

》BOOTPROTO=proto,其中,proto取下列值之一:none,引导时不使用协议;static静态分配地址;bootp,使用BOOTP协议,或dhcp,使用DHCP协议。
(2)根据上述各参数的意义,设定linpcl.lintec.edu.cn机器的设置文件如下:
[root@linpcl root]#cat /etc/sysconfig/networking/devices/ifcfg-rth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1

 
 
 
 

查看Linux下网卡状态或 是否连接(转)的更多相关文章

  1. 查看Linux下网卡状态或 是否连接

    分类: 1) 通过mii-tool指令       [root@localhost root]# mii-tool        eth0: negotiated 100baseTx-FD, link ...

  2. linux下网卡bonding配置(转)

    linux下网卡bonding配置   章节 bonding技术 centos7配置bonding centos6配置bonding 一.bonding技术 bonding(绑定)是一种linux系统 ...

  3. Linux下网卡混杂模式设置和取消

    工作中发现一个网卡工作状态不对了,查看了一下,发现这个网卡和正常工作的网卡  信息不一样,它显示的居然是混杂模式,而正常工作的是  running 模式 ,所以来了解下混杂模式怎么取消... 下文来自 ...

  4. linux下网卡bonding配置

    linux下网卡bonding配置   章节 bonding技术 centos7配置bonding centos6配置bonding 一.bonding技术 bonding(绑定)是一种linux系统 ...

  5. [转载]linux下网卡漂移导致网络不可用

    转自:https://blog.csdn.net/hyatsz/article/details/47690993 linux下网卡漂移导致网络不可用 2015年08月16日 00:48:50 hyat ...

  6. Linux 下网卡参数配置

    目录 Linux 下网卡参数配置 第一种:修改 interfaces 文件 网卡配置实例 回环参数配置 DHCP方式配置 静态 IP 地址分配 无线网卡配置 March 17, 2015 7:48 P ...

  7. 查看Linux下*.a库文件中文件、函数、变量

    查看Linux下*.a库文件中文件.函数.变量等情况在Linux 下经常需要链接一些 *.a的库文件,那怎么查看这些*.a 中包 含哪些文件.函数.变量: 1. 查看文件:ar -t xxx.a 2. ...

  8. Linux下 网卡测速

    参考: How do I verify the speed of my NIC? Linux下 网卡测速 命令: $ sudo ethtool eth0 Settings for eth0: Supp ...

  9. 查看Linux下系统资源占用常用命令

    一 top命令 1.作用top命令用来显示执行中的程序进程,使用权限是所有用户. 2.格式top [-] [d delay] [q] [c] [S] [s] [i] [n] 3.主要参数d:指定更新的 ...

随机推荐

  1. hold

    嘿嘿,很久没写博客了.一懒一拖一浮躁就不行了. 果然烦心事太多,一直懒得编程.结果还是编程才能平复我啊! 明天那什么,别担心,平常心嘛! 还好,看了几部电影,不算没收获.自己有意思就看看电影,别瞎想啥 ...

  2. 关于本地计算机无法启动Apache2

    最近因工作需要,要学习PHP的基础编程,于是学习架设PHP工作环境. 但按照教材上介绍的那样,安装了WMAP后,一直无法运行成功.后发现Apache一直都不在运行状态.到WMAP中的Apache选项中 ...

  3. 那些年被我坑过的Python——第十章Broker(rabbitMQ/redis)

    基于RabbitMQ的direct任务驱动异步RPC程序实现: RPC_dispatcher指令分发器: #!/usr/bin/env python # -*- coding:utf-8 -*- __ ...

  4. objective-c 错题

    //1, NSString *name = [[NSString alloc]initWithString:@"张三"]; NSLog(@"%d",[name ...

  5. Keil c51现No Browse information available

    keil c51 不能使用:Go to Definition of....的解决方法 最近使用keil c51 开发usb固件,当向vc一样使用Go to Definition of....时,出现警 ...

  6. 3、MyBatis.Net学习笔记之增删改

    增删改之前先说一下笔记1里提到的一个无法创建ISqlMapper对象的问题. <resultMaps> <resultMap id="FullResultMap" ...

  7. BZOJ 1032 祖玛

    Description 这是一个流行在Jsoi的游戏,名称为祖玛.精致细腻的背景,外加神秘的印加音乐衬托,彷佛置身在古老的国度里面,进行一个神秘的游戏——这就是著名的祖玛游戏.祖玛游戏的主角是一只石青 ...

  8. Reducing the Dimensionality of data with neural networks / A fast learing algorithm for deep belief net

    Deeplearning原文作者Hinton代码注解 Matlab示例代码为两部分,分别对应不同的论文: . Reducing the Dimensionality of data with neur ...

  9. 具有 Button 风格的 Panel(覆盖TCustomPanel的Paint函数,用到了ThemeServices)

    unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  10. AlgorithmsI PA2: Randomized Queues and Deques Subset

    本题的bonus是 因此方法是queue的size 达到了K, 就停止增加元素,保证queue.size() 最大时只有k. Java code: import edu.princeton.cs.al ...