Linux List Network Interfaces

Linux List Network Interfaces

Managing network interfaces is a fundamental task for any system administrator, especially those working with Linux systems. Understanding how to Linux list network interfaces is crucial for diagnosing network issues, configuring network settings, and ensuring optimal performance. This guide will walk you through the various methods to list network interfaces in Linux, providing detailed steps and explanations for each approach.

Understanding Network Interfaces in Linux

Network interfaces in Linux are the points of connection between the system and the network. They can be physical, such as Ethernet cards, or virtual, such as loopback interfaces. Each interface has a unique name and can be configured with various settings, including IP addresses, subnet masks, and gateway information.

Using the ip Command

The ip command is a powerful tool for network configuration and management. It is part of the iproute2 package, which is installed by default on most Linux distributions.

To Linux list network interfaces using the ip command, open a terminal and type the following command:

ip link show

This command will display a list of all network interfaces along with their statuses. The output will look something like this:

Interface Status
lo UP
eth0 DOWN
wlan0 UP

In this example, lo is the loopback interface, eth0 is an Ethernet interface, and wlan0 is a wireless interface. The status UP indicates that the interface is active, while DOWN means it is inactive.

πŸ’‘ Note: The ip command is preferred over older tools like ifconfig because it provides more detailed and accurate information.

Using the ifconfig Command

The ifconfig command is another tool for configuring and managing network interfaces. However, it is considered deprecated and has been replaced by the ip command in modern Linux distributions.

To Linux list network interfaces using the ifconfig command, you can use the following syntax:

ifconfig -a

This command will display all network interfaces, including those that are down. The output will include information such as the interface name, IP address, and MAC address.

⚠️ Note: The ifconfig command may not be available on all Linux distributions, especially newer ones. It is recommended to use the ip command instead.

Using the nmcli Command

The nmcli command is a command-line tool for controlling NetworkManager and reporting network status. It is particularly useful for systems that use NetworkManager to manage network connections.

To Linux list network interfaces using the nmcli command, use the following syntax:

nmcli device status

This command will display a list of all network interfaces along with their statuses and connection types. The output will look something like this:

DEVICE TYPE STATE CONNECTION
lo loopback connected --
eth0 ethernet disconnected Wired connection 1
wlan0 wifi connected Wi-Fi connection 1

In this example, the lo interface is a loopback interface, eth0 is an Ethernet interface, and wlan0 is a wireless interface. The STATE column indicates whether the interface is connected or disconnected.

πŸ’‘ Note: The nmcli command is particularly useful for systems that use NetworkManager, as it provides detailed information about network connections and their statuses.

Using the ethtool Command

The ethtool command is a utility for displaying and modifying network interface controller (NIC) settings. It is particularly useful for diagnosing network issues and configuring advanced network settings.

To Linux list network interfaces using the ethtool command, you can use the following syntax:

ethtool -i eth0

This command will display detailed information about the specified network interface, including the driver name and version. To list all network interfaces, you can use the following command:

ls /sys/class/net

This command will list all network interfaces available on the system. You can then use the ethtool command to get detailed information about each interface.

πŸ’‘ Note: The ethtool command is particularly useful for diagnosing network issues and configuring advanced network settings.

Using the lshw Command

The lshw command is a utility for displaying detailed information about the hardware configuration of the system. It can be used to list network interfaces and provide detailed information about each one.

To Linux list network interfaces using the lshw command, use the following syntax:

sudo lshw -class network

This command will display detailed information about all network interfaces on the system, including the interface name, driver, and configuration settings. The output will look something like this:

description product vendor physical id bus info logical name version serial size capacity width clock configuration resources
Ethernet interface Ethernet Controller I211 Intel Corporation 0 0000:00:1f.6 eth0 00 00:1a:2b:3c:4d:5e 1Gbit/s 1Gbit/s 32bits 33MHz autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k firmware=0.13-4 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s irq:28 memory:f7c00000-f7c1ffff
Ethernet interface Wireless 8265 / 8275 Intel Corporation 0 0000:00:14.3 wlan0 00 00:1a:2b:3c:4d:5f 1Gbit/s 1Gbit/s 32bits 33MHz autonegotiation=on broadcast=yes driver=iwlwifi driverversion=5.4.0-42-generic firmware=36.77d01142.0 8265-36.ucode latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s irq:16 memory:f7c00000-f7c1ffff

In this example, the output includes detailed information about the Ethernet and wireless interfaces, including the driver name, version, and configuration settings.

πŸ’‘ Note: The lshw command provides detailed information about the hardware configuration of the system, making it a useful tool for diagnosing network issues.

Using the ls Command

The ls command is a basic utility for listing directory contents. It can also be used to list network interfaces by examining the contents of the /sys/class/net directory.

To Linux list network interfaces using the ls command, use the following syntax:

ls /sys/class/net

This command will list all network interfaces available on the system. The output will look something like this:

Interface
lo
eth0
wlan0

In this example, the output includes the loopback interface lo, the Ethernet interface eth0, and the wireless interface wlan0.

πŸ’‘ Note: The ls command is a basic utility for listing directory contents, making it a quick and easy way to list network interfaces.

Using the netstat Command

The netstat command is a networking utility tool that can be used to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It is particularly useful for diagnosing network issues and monitoring network activity.

To Linux list network interfaces using the netstat command, use the following syntax:

netstat -i

This command will display a list of all network interfaces along with their statistics, including the number of packets received and transmitted. The output will look something like this:

Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
lo 65536 0 12345 0 0 0 12345 0 0 0 LRU
eth0 1500 0 1234567 0 0 0 1234567 0 0 0 BMRU
wlan0 1500 0 1234567 0 0 0 1234567 0 0 0 BMRU

In this example, the output includes the loopback interface lo, the Ethernet interface eth0, and the wireless interface wlan0. The statistics include the number of packets received and transmitted, as well as any errors or drops.

πŸ’‘ Note: The netstat command is particularly useful for diagnosing network issues and monitoring network activity.

Using the ss Command

The ss command is a modern replacement for the netstat command. It is used to dump socket statistics and provides more detailed and accurate information about network connections and interfaces.

To Linux list network interfaces using the ss command, use the following syntax:

ss -tuln

This command will display a list of all network interfaces along with their listening sockets and connection states. The output will look something like this:

Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
tcp LISTEN 0 128 127.0.0.1:631 0.0.0.0:*
tcp LISTEN 0 128 [::]:22 [::]:*
tcp LISTEN 0 128 [::1]:631 [::]:*

In this example, the output includes information about the listening sockets on various interfaces, including the local and peer addresses and ports.

πŸ’‘ Note: The ss command is a modern replacement for the netstat command and provides more detailed and accurate information about network connections and interfaces.

Using the dmesg Command

The dmesg command is used to examine or control the kernel ring buffer. It can be used to display messages related to network interfaces, including information about interface detection and configuration.

To Linux list network interfaces using the dmesg command, use the following syntax:

dmesg | grep -i eth

This command will display messages related to Ethernet interfaces. You can modify the grep pattern to search for other types of interfaces, such as wireless interfaces.

πŸ’‘ Note: The dmesg command is useful for diagnosing network issues by examining kernel messages related to network interfaces.

Using the ifquery Command

The ifquery command is a utility for querying network interface information. It is part of the net-tools package, which is installed by default on many Linux distributions.

To Linux list network interfaces using the ifquery command, use the following syntax:

ifquery -a

This command will display a list of all network interfaces along with their statuses and configuration settings. The output will look something like this:

Interface Status IP Address MAC Address
lo UP 127.0.0.1 00:00:00:00:00:00
eth0 DOWN 192.168.1.100 00:1a:2b:3c:4d:5e
wlan0 UP 192.168.1.101 00:1a:2b:3c:4d:5f

In this example, the output includes the loopback interface lo, the Ethernet interface eth0, and the wireless interface wlan0. The status column indicates whether the interface is up or down, and the IP and MAC addresses are also displayed.

πŸ’‘ Note: The ifquery command is useful for querying network interface information and is part of the net-tools package.

Using the iproute2 Package

The iproute2 package is a collection of utilities for controlling and monitoring network interfaces and routing. It includes the ip command, which is the preferred tool for managing network interfaces in modern Linux distributions.

To Linux list network interfaces using the iproute2 package, you can use the following commands:

ip link show
ip addr show

The ip link show command will display a list of all network interfaces along with their statuses, while the ip addr show command will display detailed information about each interface, including IP addresses and subnet masks.

πŸ’‘ Note: The iproute2 package is the preferred tool for managing network interfaces in modern Linux distributions.

Using the NetworkManager Command

The NetworkManager command is a system service that provides network connectivity to the system. It manages network interfaces and connections, and can be controlled using the nmcli command.

To Linux list network interfaces using

Related Terms:

  • show interfaces in linux
  • debian linux list network interfaces
  • show network interfaces linux
  • linux list all ip addresses
  • linux list physical network interfaces
  • linux list network devices