In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Linux how to check the available network interfaces, the article is very detailed, has a certain reference value, interested friends must read it!
Method 1 using the ifconfig command using the ifconfig command to view the network interface 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=4098mtu 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=73mtu 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 (289.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=4163mtu 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 c018: 85 txqueuelen 50 RX packets 47 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 shown in the output above There are two network interfaces on my Linux machine, which are 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 uses the ip command in the latest version of Linux, the ifconfig command has been deprecated. You can use the ip command to list the network interfaces, as follows:
Sample output of $ip link show:
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:00 2: 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:ff 3: 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 use the / sys/class/net directory Linux kernel to save 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.
Sample output of $ls / sys/class/net:
Enp5s0 lo wlp9s0 method 4 uses the / proc/net/dev directory in the Linux operating system, and 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:
Sample output of $cat / proc/net/dev:
Inter- | Receive | Transmit face | bytes packets errs drop fifo frame compressed multicast | bytes packets errs drop fifo colls carrier compressed wlp9s0: 629189631 566078 00 00 00 60822472 300922 00 00 enp5s0: 00 00 00 lo: 303980988 171420 00 00 00 303980988 171420 00 00 method 5 use the netstat command netstat command to list a variety of different information, such as network connections, routing tables, interface statistics, camouflage connections and multicast members.
Sample output of $netstat-I:
Kernel Interface table Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg lo 65536 171420 171420 171420 LRU wlp9s0 1500 565625 00 300543 000 BMRU Please note 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 using 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
The above $nmcli connection show is all the contents of the article "how to check the available network interfaces for Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.