Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check the network card information on Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to check the network card information on the Linux". In the daily operation, I believe that many people have doubts about how to check the network card information on the Linux. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to check the network card information on the Linux". Next, please follow the editor to study!

By default, you configure the primary network interface when you set up the server. This is part of the build work that everyone does. Sometimes you may need to configure additional network interfaces for a variety of reasons.

This can be a network binding bonding/ collaboration teaming to provide high availability, or it can be a separate interface for application requirements or backups.

To do this, you need to know how many interfaces the computer has and their speed to configure them.

There are many commands to check for available network interfaces, but we only use the ip command. In the future, we will write a separate article to introduce all these tools.

In this tutorial, we will show you available network card (NIC) information, such as interface name, associated IP address, MAC address, and interface speed.

What is the ip command

The ip command is similar to ifconfig in that it assigns static IP addresses, routes, default gateways, and so on.

# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6:: 1/128 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether fa:16:3e:a0:7d:5a brd ff:ff:ff:ff:ff:ff inet 192.168. 1.101 take 24 brd 192.168.1.101 scope global eth0 inet6 fe80::f816:3eff:fea0:7d5a/64 scope link valid_lft forever preferred_lft forever what is the ethtool command

Ethtool is used to query or control network drivers or hardware settings.

# ethtool eth01) how to use the ip command on Linux to check available network interfaces

When you run the ip command without any arguments, it provides a lot of information, but if only available network interfaces are needed, use the following custom ip command.

# ip a | awk'/ state UP/ {print $2} 'eth0:eth2:2) how to use the ip command on Linux to check the IP address of a network interface

If you only want to see which interface the IP address is assigned to, use the following custom ip command.

# ip-o a show | cut-d''- f 2MAC 7 or ip a | grep-I inet | awk'{print $7, $2}'lo 127.0.0.1) how to use the ip command on Linux to check the MAC address of a network card.

If you only want to view the network interface name and the corresponding MAC address, use the following format.

Check the MAC address of a specific network interface:

# ip link show dev eth0 | awk'/ link/ {print $2} '00lv 00lv 00R 55Rd 43R 5c

Check the MAC addresses of all network interfaces and create the script:

# vi / opt/scripts/mac-addresses.sh #! / bin/ship a | awk'/ state UP/ {print $2}'| sed's Uniplex while read output;do echo'| while read output;do echo $output: ethtool-P $outputdone

Run the script to get the MAC addresses of multiple network interfaces:

# sh / opt/scripts/mac-addresses.sh eth0:Permanent address: 00:00:00:55:43:5ceth2:Permanent address: 00:00:00:55:43:5d4) how to check the speed of a network interface using the ethtool command on Linux

If you want to check the speed of the network interface on Linux, use the ethtool command.

Check the speed of a specific network interface:

# ethtool eth0 | grep "Speed:" Speed: 10000Mb/s

Check the speed of all network interfaces and create the script:

# vi / opt/scripts/port-speed.sh #! / bin/ship a | awk'/ state UP/ {print $2}'| sed's while read output;do echo output: ethtool $output | grep "Speed:" done

Run the script to get the speed of multiple network interfaces:

# sh / opt/scripts/port-speed.sh eth0:Speed: 10000Mb/seth2:Speed: 10000Mb/s5) Shell script for verifying Nic information

Through this shell script you can collect all the above information, such as the name of the network interface, the IP address of the network interface, the MAC address of the network interface, and the speed of the network interface. Create the script:

# vi / opt/scripts/nic-info.sh #! / bin/shhostnameecho "-" for iname in $(ip a | awk'/ state UP/ {print $2}') do echo "$iname" ip a | grep-A2 $iname | awk'/ inet/ {print $2}'ip a | grep-A2 $iname | awk'/ link/ {print $2} 'ethtool $iname | grep "Speed:" done

Run the script to check the Nic information:

# sh / opt/scripts/nic-info.sh vps.2daygeek.com-eth0:192.168.1.101/2400:00:00:55:43:5cSpeed: 10000Mb/seth2:192.168.1.102/2400:00:00:55:43:5dSpeed: 10000Mb/s at this point, the study on "how to check network card information on Linux" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report