In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to view available network interfaces in Linux". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to view available network interfaces in Linux".
Find available network interfaces in Linux
We can use the following methods to find available network interfaces.
Method 1 use the ifconfig command
Using the ifconfig command to view network interfaces is still the most commonly used method. I'm sure there are still many Linux users who still use this method.
$ifconfig-a
Sample output:
Enp5s0: flags=4098 mtu 1500 ether 24:b6:fd:37:8b:29 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6: 1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 171420 bytes 303980988 .8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 171420 bytes 303980988 (289.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlp9s0: flags=4163 mtu 1500 inet 192.168.225.37 netmask 255.255.255.0 broadcast 192.168.225.255 inet6 2409:4072:6183:c604:c218:85ff:fe50:474f prefixlen 64 scopeid 0x0 inet6 fe80::c218:85ff:fe50:474f prefixlen 64 scopeid 0x20 ether c0GV 1885 JV 50GV 474f Txqueuelen 1000 (Ethernet) RX packets 564574 bytes 628671925 (599.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 299706 bytes 60535732 (57.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
As the output above shows, there are two network interfaces on my Linux machine, called enp5s0 (wired network card on motherboard) and wlp9s0 (wireless network card). Lo is a loopback network card, which is used to access local network services, usually its IP address is 127.0.0.1.
We can also use the same ifconfig in many UNIX variants such as FreeBSD to list available network cards.
Method 2 use the ip command
In the Linux version of * *, the ifconfig command has been deprecated. You can use the ip command to list the network interfaces, as follows:
$ip link show
Sample output:
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:002: enp5s0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 24:b6:fd:37:8b:29 brd ff:ff:ff:ff:ff:ff3: wlp9s0: mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 link/ether c0:18:85:50:47:4f brd ff:ff:ff:ff:ff:ff
You can also use the following command to check.
$ip addr$ ip-s link
Have you noticed? These commands also show the status of the network interfaces that have been connected. If you take a closer look at the output above, you will notice that my wired network card is not connected to the network cable (as can be seen from the DOWN in the output above). In addition, my wireless network card is connected (as can be seen from the UP in the output above). For more details, check out our previous guide to see the connected status of the network interface in Linux.
These two commands (ifconfig and ip) are enough to check the available network cards in your LInux system.
However, there are other ways to list the network interfaces in Linux, so let's move on.
Method 3 uses the / sys/class/net directory
The Linux kernel keeps the details of the network interfaces in the / sys/class/net directory, and you can verify that the list of available interfaces matches the previous results by looking at the contents of this directory.
$ls / sys/class/net
Sample output:
Enp5s0 lo wlp9s0 method 4 uses the / proc/net/dev directory
In Linux operating systems, the file / proc/net/dev contains information about the network interface.
To view the available network cards, simply use the following command to view the contents of the file above:
$cat / proc/net/dev
Sample output:
Inter- | Receive | Transmitface | bytes packets errs drop fifo frame compressed multicast | bytes packets errs drop fifo colls carrier compressedwlp9s0: 629189631 566078 00 00 00 60822472 300922 00 00 0enp5s0: 00 00 00 0lo: 303980988 171420 00 00 00 303980988 171420 00 00 method 5 use the netstat command
The netstat command can list a variety of different information, such as network connections, routing tables, interface statistics, camouflage connections, and multicast members.
$netstat-I
Sample output:
Kernel Interface tableIface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flglo 65536 171420 00 0 171420 00 0 LRUwlp9s0 1500 565625 00 0 300543 00 0 BMRU
Notice that netstat is deprecated and the alternative command for netstat-I is ip-s link. It is also important to note that this method will list only the active interfaces, not all available interfaces.
Method 6 uses the nmcli command
Nmcli is a command-line tool for controlling NetworkManager and reporting network status. It can be used to create, display, edit, delete, activate, deactivate network connections and display network status.
If you have NetworkManager installed on your Linux system, you can use the following command to list the possible network interfaces using nmcli:
$nmcli device status
Or
$nmcli connection show
Now that you know how to find available network interfaces in Linux, take a look at the guide below to learn how to configure IP addresses in Linux.
Thank you for your reading, the above is the content of "how to view available network interfaces in Linux". After the study of this article, I believe you have a deeper understanding of how to view available network interfaces in Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.