linux查看網(wǎng)卡的方法:1、“ifconfig”命令;2、“l(fā)spci |grep -i \’eth\’”或“l(fā)spci | grep -i net”命令;3、“iwconfig”命令;4、使用ethtool工具,查詢配置網(wǎng)卡參數(shù)。
本教程操作環(huán)境:red hat enterprise linux 6.1系統(tǒng)、dell g3電腦。
一、首先是最簡單明了的兩個命令, ifconfig和lspci。
1.ifconfig:最常用的配置和查看網(wǎng)絡(luò)接口信息的命令,服務(wù)器上執(zhí)行此命令會得到類下文的內(nèi)容,一下內(nèi)容可看到多個設(shè)備和設(shè)備狀態(tài)、信息。
[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總線上的設(shè)備,通過grep過濾后可得到網(wǎng)卡設(shè)備列表,下文可看到我pci總線上的網(wǎng)絡(luò)設(shè)備有倆,是兩個intel的網(wǎng)卡:
[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 :用于查看無線網(wǎng)絡(luò),如果你設(shè)備上有無線網(wǎng)卡此時可用此命令來查看,我的設(shè)備上并沒有無線網(wǎng)卡設(shè)備,因此會會得到如下信息。
[oracle@mori~]$iwconfiglonowirelessextensions.eth0nowirelessextensions.pan0nowirelessextensions.eth1nowirelessextensions.
二、除以上幾個命令外有個神秘而強大的工具較 ethtool1.ethtool 命令主要用于查詢配置網(wǎng)卡參數(shù)。
2.用法:ethtool ethn//其中 n 是對應(yīng)網(wǎng)卡的編號,如eth0、eth1等等
3.ethtool的功能較多,這里不一一贅述,如有需求和查看其說明頁 man ethtool,這里單獨拿出來講的一個功能,這個功能適用于如下場景:你的 服務(wù)器有多個網(wǎng)卡并且已經(jīng)配置好運行當(dāng)中,你卻沒記得eth0、eth1、eth2…..分別對應(yīng)的是哪個物理的網(wǎng)卡,此時可以使用如下命令:
[root@morioracle]#ethtool-peth0
此時就會看到 eth0 對應(yīng)的物理口一個燈在不停的閃爍,對了。這就是我們在系統(tǒng)看到的那個叫eth0的網(wǎng)卡了,就是這么簡單。