温馨提示  2024年 6月我们已经停止开发者板块文章内容更新,谢谢来访。存档数据
知识 2023-08-21 43 次阅读

四个步骤教你在linux下看网卡信息

   

一、首先是最通俗易懂的两个命令, ifconfig和lspci。

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

[oracle@mori~]$ifconfigeth0linkencap:ethernethwaddr00:0c:29:a4:5a:bfinetaddr:192.168.1.160bcast:192.168.1.255mask:255.255.255.0inet6addr:fe80::20c:29ff:fea4:5abf/64scope:linkupbroadcastrunningmulticastmtu:1500metric:1rxpackets:1650errors:0dropped:0overruns:0frame:0txpackets:112errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:1000rxbytes:134000(130.8kib)txbytes:12228(11.9kib)eth1linkencap:ethernethwaddr00:0c:29:a4:5a:c9inetaddr:192.168.1.161bcast:192.168.1.255mask:255.255.255.0inet6addr:fe80::20c:29ff:fea4:5ac9/64scope:linkupbroadcastrunningmulticastmtu:1500metric:1rxpackets:1618errors:0dropped:0overruns:0frame:0txpackets:88errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:1000rxbytes:125909(122.9kib)txbytes:9320(9.1kib)lolinkencap:localloopbackinetaddr:127.0.0.1mask:255.0.0.0inet6addr:::1/128scope:hostuploopbackrunningmtu:16436metric:1rxpackets:182errors:0dropped:0overruns:0frame:0txpackets:182errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:0rxbytes:10340(10.0kib)txbytes:10340(10.0kib)

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

[oracle@mori~]$lspci|grep-i'eth'02:01.0ethernetcontroller:intelcorporation82545emgigabitethernetcontroller(copper)(rev01)02:06.0ethernetcontroller:intelcorporation82545emgigabitethernetcontroller(copper)(rev01)[oracle@mori~]$lspci|grep-inet02:01.0ethernetcontroller:intelcorporation82545emgigabitethernetcontroller(copper)(rev01)02:06.0ethernetcontroller:intelcorporation82545emgigabitethernetcontroller(copper)(rev01)

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

[oracle@mori~]$iwconfiglonowirelessextensions.eth0nowirelessextensions.pan0nowirelessextensions.eth1nowirelessextensions.

二、除以上几个命令外有个神秘而强大的工具较 ethtool1.ethtool 命令主要用于查询配置网卡参数。

2.用法ethtool ethn//其中 n 是对应网卡的编号,如eth 0. eth1等等

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

[root@morioracle]#ethtool-peth0

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