As a system administrator or a regular user, you may want to know the available network interface in your Linux system. It is often used to know the interface name, and its status, and to manage network configurations.
In this tutorial, we learn how to list network interfaces on the Linux system.
Listing available network interfaces in Linux
Here learn 11 ways to list available network interfaces in Linux.
1. Using ip command
The ip command is a powerful modern substitute for the popular ifconfig command. It is one of the most popular and simple methods for listing network interfaces.
This command has three methods for listing available interfaces, which we will cover in this section. The ip command displays detailed information about your system's network interfaces in beautiful color.
To display available interfaces on your system use the "ip addr" command:
If you are as lazy as I am to type, you can use the following short command for the above command. This command will help you save a few keystrokes.
You can also use the following lengthy "ip link show" command to list the network interfaces; however, this command will provide less information than the two preceding commands.
ip link show
The preceding command displays a list of all network interfaces on the system. The output above shows that the system has four interfaces: loopback interface (lo), ethernet network interface (eth0), wireless network interface (wlan0), a virtual bridge network interface created by docker (docker0), and another virtual bridge network interface created by virtualbox (vboxnet0) as well as other statistics.
This command will also display some useful information about the network interfaces, such as ip addresses (IPv4 and IPv6), network interface status whether it's UP or DOWN, network interface MAC address, broadcast address, and so on.
Note: Depending on your system's hardware or the distribution you use, you may have different network interface names.
2. Using nmcli
Network manager command line interface is abbreviated as nmcli. This command also displays network interface information.
The nmcli command comes standard with most Debian distributions that include a Graphical User Interface Desktop Environment.
However, if you are working on a system with no Graphical User Interface(GUI) or if is not installed by default, you will need to install it. I will not go into detail about the installation process in this article, but you can do your own research on how to do so. The procedure is fairly straightforward.
Run the following command in Terminal to see a list of your system's network interfaces:
nmcli device status
The above command displays summary information about the network interfaces on the system which includes the network device names. The nmcli command can also be used to list the available interfaces and their connections on Linux. The following command demonstrates that:
nmcli connection show or nmcli con show
3. Using netstat
The netstat command can also be used to display a list of available network interfaces on your system. To do so,use the netstat command together with the -i option, as shown below:
The above command lists the available network interfaces in your system, as well as other useful information such as the number of sent and received packets, the interface's Maximum Transfer Unit (MTU), and so on.
5. Using ifconfig command
Though it has become obsolete, the ifconfig command is still the most commonly used tool for listing network interface information on a system.
It is included with many Linux distributions. By simply running the ifconfig command without any options, you can list the network interfaces available in your system.
Besides only showing the available interfaces, the above command will display additional useful information about a specific network interface, such as ip address, netmask, broadcast address, Maximum Transfer Unit (MTU) size, number of packets sent, received, and dropped, transmission errors (tx errors), collions, and so on.
6. From /proc/net/dev file
The /proc/net/dev file in Linux operating systems logs statistics about network available interfaces. The information in /proc/net/dev is identical to that obtained with the ifconfig command.
Simply view the contents of the /proc/net/dev file with your favorite file-viewing command to see the available network interfaces. In this example, I'll use bat, a modern replacement for the popular cat command.
8. By Listing /sys/class/net/ directory
In Linux, everything is a file, from system information to hardware devices. The directory /sys/class/net contains information about the system's network devices. We can list the contents of this directory to view available network interfaces as shown below:
As shown in the preceding example, the /sys/class/net directory contains directories for each available network interface. As I mentioned earlier, every file in Linux is a file, and this directory contains files for each specific piece of information on the interface, such as transmission speed, transmission errors, ip address, and so on.
9. Using hwinfo command
hwinfo is used to probe for hardware in the system. It can be used to generate a system overview log that can be used for support later on.
Because this tool may not be pre-installed on your system, you must install it using your system's package manager.
If installed, use the hwinfo utility to list the network interface names as follows:
sudo hwinfo --short --network
10. Using lshw command
Lshw is a small tool that extracts detailed information about the machine's hardware configuration. It can provide precise memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, and so on.
This tool may not come pre-installed on your system, so you must install it before using it.
To display a list of network interfaces on the system, use the lshw utility together with the options shown below :
sudo lshw -class network -short
11. Using iwconfig
The iwconfig command can also be used to find out which network interfaces are available on the system. This tool may also not come pre-installed on your system, so you must install it before using it.
To find the available network interfaces on your Linux system simply execute the iwconfig command on your terminal without any options, as shown below:
That concludes this article, which I hope you found useful. This guide covered ten different methods for discovering and listing network interfaces that are available on Linux.
Keep in mind that the methods discussed are not the only ways to accomplish this; the good thing about Linux is that it lets you to perform the same task in a variety of ways, so feel free to explore other options and share your findings in the comments.