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. Javascript中null值,特别注意的两点

    null 是一个javascript字面量,表示空值,就是没有对象被呈现.他是javascript原始值之一.null值常被放在期望一个对象上,但是不引用任何对象的参数位置,也就是说对象的初始化. 我 ...

  2. python unicode&str 转化

    从数据库中取出的值是Unicode编码的 需要转化为str才能正常使用 参考: http://www.mamicode.com/info-detail-308445.html

  3. 第一个程序点亮一个LED灯

    #include <reg52.h> // 引用52包文件 可以理解为命名空间 sbit P1_0 = P1^0;   // 定义P1管脚0 void main()             ...

  4. 使用C语言获取当前系统的时间

    要想使用C语言来获取当前系统的时间,办法如下: 需要提前准备的工作: #include <stdio.h> #include <time.h> #include <std ...

  5. sdk manager更新失败,显示Download interrupted: read timed out,应该如何解决?

    今天开始第一天学习Android,就遇到一个大问题.sdk manager无法自动更新,总在提示超时!!! 经过网上查询发现问题原因是. 在利用android sdk manager更新时失败,具体情 ...

  6. intent.addFlags

     一.Activity和Task(栈)的关系 Task就像一个容器,而Activity就相当与填充这个容器的东西,第一个东西(Activity)则会处于最下面,最后添加的东西(Activity)则会在 ...

  7. JS拖动div的原理

    要实现移动窗体,首先要捕获三个参数:1.a = 鼠标点击时的坐标.2.b = 被移动窗体的左顶点坐标.3.c = 鼠标移动时的坐标.然后还要算出你鼠标无论点击窗体哪个位置,移动改变的都是 (d = 窗 ...

  8. X-Plosives

    uvaLive 3644:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pa ...

  9. hdu 5150 Sit sit sit

    http://acm.hdu.edu.cn/showproblem.php?pid=5151 直接判断是不是素数,然后再注意1就行. #include <cstdio> #include ...

  10. 要开始深入VMM了。

    得到一个VMM机器所有的节点状态 Quick one-liner to generate a CSV of virtual machines, sorted by their hosts. Repor ...