• 技术文章 >运维 >linux运维

    linux怎么查看网卡

    藏色散人藏色散人2023-01-05 14:16:20原创56

    linux查看网卡的方法:1、通过“ifconfig”命令查看网络接口信息;2、通过“lspci |grep -i 'eth'”或通过“lspci | grep -i net”命令查看网卡设备列表;3、通过“iwconfig”命令查看设备上是否有无线网卡设备;4、通过“ethtool”命令查询配置网卡参数。

    本教程操作环境:linux7.5系统、Dell G3电脑。

    linux怎么查看网卡?

    linux查看网卡信息的几种方法(命令)

    这两天由于测试需求需需要查看服务器上有几个网卡以及每个网卡信息等,因此收集一些查看这些信息的方法。

    一、首先是最简单明了的两个命令, ifconfig和lspci。

    1.ifconfig: 最常用的配置和查看网络接口信息的命令,服务器上执行此命令会得到类下文的内容,一下内容可看到多个设备和设备状态、信息。

    [oracle@mori ~]$ ifconfig
          eth0      Link encap:Ethernet  HWaddr 00:0C:29:A4:5A:BF  
              inet addr:192.168.1.160  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fea4:5abf/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1650 errors:0 dropped:0 overruns:0 frame:0
              TX packets:112 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:134000 (130.8 KiB)  TX bytes:12228 (11.9 KiB)
     
         eth1      Link encap:Ethernet  HWaddr 00:0C:29:A4:5A:C9  
              inet addr:192.168.1.161  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fea4:5ac9/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1618 errors:0 dropped:0 overruns:0 frame:0
              TX packets:88 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:125909 (122.9 KiB)  TX bytes:9320 (9.1 KiB)
     
         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:182 errors:0 dropped:0 overruns:0 frame:0
              TX packets:182 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:10340 (10.0 KiB)  TX bytes:10340 (10.0 KiB)

    2.lspci |grep -i 'eth' 或 lspci | grep -i net命令:可列出每个pci总线上的设备,通过grep过滤后可得到网卡设备列表,下文可看到我pci总线上的网络设备有俩,是两个intel的网卡:

      [oracle@mori ~]$ lspci |grep -i 'eth'
      02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
      02:06.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
     
      [oracle@mori ~]$ lspci | grep -i net
      02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
      02:06.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

    3.iwconfig :用于查看无线网络,如果你设备上有无线网卡此时可用此命令来查看,我的设备上并没有无线网卡设备,因此会会得到如下信息。

      [oracle@mori ~]$ iwconfig
      lo        no wireless extensions.
      eth0      no wireless extensions.
      pan0      no wireless extensions.
      eth1      no wireless extensions.

    二、除以上几个命令外有个神秘而强大的工具较 ethtool

    1.ethtool 命令主要用于查询配置网卡参数。

    2.用法:ethtool ethN //其中 N 是对应网卡的编号,如eth0、eth1等等

    3.ethtool的功能较多,这里不一一赘述,如有需求和查看其说明页 man ethtool,这里单独拿出来讲的一个功能,这个功能适用于如下场景:你的 服务器有多个网卡并且已经配置好运行当中,你却没记得eth0、eth1、eth2.....分别对应的是哪个物理的网卡,此时可以使用如下命令:

      [root@mori oracle]# ethtool -p eth0

    此时就会看到 eth0 对应的物理口一个灯在不停的闪烁,对了。这就是我们在系统看到的那个叫eth0的网卡了,就是这么简单。

    推荐学习:《Linux视频教程

    以上就是linux怎么查看网卡的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:网卡 linux
    上一篇:linux查看内存大小的命令是什么 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • linux的重启命令是什么• linux怎么查看版本信息• linux怎么查看目录占用空间大小• linux明明有文件却找不到怎么办• linux查看内存大小的命令是什么
    1/1

    PHP中文网