Linux various network card information query methods



1. View the basic information of the network card: ifconfig


ifconfig (network interfaces configuring)
is a command used to display or configure network devices in Linux.

:~> ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.5.1.1  netmask 255.255.255.19  broadcast 10.5.1.255
        ether e8:4d:d0:b4:37:ad  txqueuelen 1000  (Ethernet)
        RX packets 483834396600  bytes 683233729924158 (621.3 TiB)
        RX errors 0  dropped 20  overruns 0  frame 0
        TX packets 95269964773  bytes 55409527168264 (50.3 TiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 138146336  bytes 16565271947 (15.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 138146336  bytes 16565271947 (15.4 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


2. View wireless network device information: iwconfig


iwconfig is a command similar to ifconfig. It is
used to configure wireless network devices or display wireless network device information. It
is one of the user-level configuration tools of Linux Wireless Extensions (LWE).

However,
because CentOS does not install LWE by default, additional installation is required to use iwconfig.
Otherwise you will encounter this problem:

:~> iwconfig
-bash: iwconfig: command not found

The solution to this problem is very simple, just install wireless-tools:

//安装 wireless-tools
:~> yum install -y wireless-tools


Three, check the network card traffic: sar


sar,
System Activity Reporter, system activity report;

System activities can be reported from many aspects,
including: network card usage, file read and write, system call usage,
disk I/O, CPU efficiency, memory usage, process activities, and IPC-related activities.

//查看网卡流量,每秒输出一次,输出2次。
:~> sar -n DEV 1 2 

Linux  (testsvr)   03/05/2021       _x86_64_ (24 CPU)

05:59:30 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
05:59:31 PM      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:59:31 PM      eth1   6527.00    827.00   9426.35    304.65      0.00      0.00      0.00
05:59:31 PM      sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:59:31 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

05:59:31 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
05:59:32 PM      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:59:32 PM      eth1  59310.00   3147.00  87534.18    208.18      0.00      0.00      0.00
05:59:32 PM      sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:59:32 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
Average:         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth1  32918.50   1987.00  48480.27    256.41      0.00      0.00      0.00
Average:         sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00


Four, check the network card model and quantity: lspci

lspci, that is, display all pci device information.
PCI is a kind of bus, and the devices connected through the PCI bus are PCI devices.


:~>   lspci  |grep Ethernet

02:00.0 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
02:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)


:~>  lspci -vvv |grep Ethernet

02:00.0 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
02:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)


5. Check the network card driver: ethtool and lspci


Ethtool is a command used to query and set network card parameters.
The information it displays comes from the network card driver layer, which is the link layer of the TCP/IP protocol.

:~>  ethtool -i eth1 | grep driver

driver: ixgbe

lspci, a command to display all pci device information.

:~>  lspci -vvv  |  grep  -A10  -B10 driver 

...
02:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
   Subsystem: Intel Corporation Device 0000
   Physical Slot: 0-2
   Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
   Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
   Latency: 0, Cache Line Size: 64 bytes
   Interrupt: pin B routed to IRQ 36
   Region 0: Memory at 96000000 (64-bit, prefetchable) [size=2M]
   Region 2: I/O ports at 2000 [size=32]
   Region 4: Memory at 96400000 (64-bit, prefetchable) [size=16K]
   Capabilities: <access denied>
   Kernel driver in use: ixgbe
...


Six, check the network card rate: ethtool



:~>  ethtool eth1  |  grep -i speed

   Speed: 10000Mb/s




Seven, display the information when the network card is loaded when the system is booted: dmesg


:~>   dmesg |grep -i eth

[    6.859045] virtio_net virtio0 eth1: renamed from eth0
[    9.976245] 8021q: adding VLAN 0 to HW filter on device eth1

Guess you like

Origin blog.csdn.net/weixin_44648216/article/details/114662068