How to list all physical Ethernet ports on Linux server

Unlike conventional servers, rack servers must be resilient and often contain several physical Ethernet ports or NICs (Network Interface Cards) to be able to connect to multiple networks at the same time.

In addition to rack servers, some industrial or dedicated PCs also come with multiple Ethernet or NIC ports.

Either way, here's how you can find out the number of Ethernet ports on a Linux server without going to the server room to check.

Why does the server have multiple physical Ethernet ports?

Most rack servers or industrial PCs have multiple NICs (Network Interface Cards) for the following reasons:

  1. Network segmentation : Multiple physical ports allow the server to connect to multiple networks at the same time. This provides better security and performance.
  2. Virtualization : Virtualization is key to ensuring that your server is using resources optimally. It also allows you to run different types of network servers on a single hardware server. Having multiple interfaces also allows virtual segmentation of virtual machine networks.
  3. Redundancy : Multiple physical interfaces make your server network more resilient because you can still contact your server when a cable or interface has hardware problems.

In general, multiple network interfaces in your server network provide better performance and more robustness.

List physical Ethernet ports on Linux server

The lspci command lists all the PCI (Peripheral Component Interconnect) devices on your machine. PCI is a standard protocol that allows computers to connect and communicate through physical interfaces such as NICs, video cards, etc.

 

Since we are only interested in Ethernet ports, filter the list accordingly using the grep command as follows:

 lspci | grep -i ethernet

How to list all physical Ethernet ports on Linux server Picture 1How to list all physical Ethernet ports on Linux server Picture 1

The output lists all the NICs on this server (as you can see, there are 8 NICs in total). In addition to listing the NICs, you'll also know the NIC's manufacturer and its type: Ethernet, in this case.

To display only the total number of ports without a detailed list, use the following command:

lspci | grep Ethernet | wc -l

Secure Linux server administration rights

Servers that come with multiple physical Ethernet ports offer better performance, power, and flexibility than PCs that come with only one NIC.

Linux comes with many built-in tools, such as the ip command, to configure and manage your network.

4.5 ★ | 2 Vote