One of the common task we do after installing a Linux system is
network configuration. Of course, you can configure network interfaces
during the installation time. But, some of you might prefer to do it
after installation or change the existing settings. As you know already,
you must first know how many interfaces are available on the system
in-order to configure network settings from command line. This brief
tutorial addresses all the possible ways to find available network
interfaces on Linux and Unix operating systems.
Find Available Network Interfaces On Linux
We can find the available network cards in couple ways.
Method 1 – Using ‘ifconfig’ Command:
The most commonly used method to find the network interface details is using ‘ifconfig’ command. I believe some of Linux users might still use this.
As you see in the above output, I have two network interfaces namely enp5s0 (on board wired ethernet adapter) and wlp9s0 (wireless network adapter) on my Linux box. Here, lo is loopback interface, which is used to access all network services locally. It has an ip address of 127.0.0.1.
We can also use the same ‘ifconfig’ command in many UNIX variants, for example FreeBSD, to list available network cards.
Method 2 – Using ‘ip’ Command:
The ‘ifconfig’ command is deprecated in the latest Linux versions. So you can use ‘ip’ command to display the network interfaces as shown below.
$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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
Find Available Network Interfaces Using ‘ip’ Command On Linux
You can also use the following commands as well.
$ ip addr
$ ip -s link
Did you notice that these command also shows the connected state of
the network interfaces? If you closely look at the above output, you
will notice that my Ethernet card is not connected with network cable
(see the word “DOWN” in the above output). And wireless network card is connected (See the word “UP”). For more details, check our previous guide to find the connected state of network interfaces on Linux.
These two commands (ifconfig and ip) are just enough to find the available network cards on your Linux systems.
However, there are few other methods available to list network interfaces on Linux. Here you go.
The Linux Kernel saves the network interface details inside /sys/class/net directory. You can verify the list of available interfaces by looking into this directory.
$ ls /sys/class/net
enp5s0 lo wlp9s0
In Linux operating systems, /proc/net/dev file contains statistics about network interfaces.
To view the available network cards, just view its contents using command:
Please be mindful that netstat is obsolete. The Replacement for
“netstat -i” is “ip -s link”. Also note that this method will list only
the active interfaces, not all available interfaces.
Method 6: Using ‘nmcli’ command
The nmcli is nmcli is a command-line tool for controlling
NetworkManager and reporting network status. It is used to create,
display, edit, delete, activate, and deactivate network connections and
display network status.
If you have Linux system with Network Manager installed, you can list
the available network interfaces using nmcli tool using the following
$ nmcli device status
$ nmcli connection show
You know now how to find the available network interfaces on Linux. Next, check the following guides to know how to configure IP address on Linux.