Available Network Interfaces On Linux/Ubuntu - 6 Quick Solutions

If you need a solution for quickly finding information about the network interfaces attached to the server or computer, then choose one of the solutions below, any of which is useful for certain technical situations.

1) using lshw , a small tool to extract detailed information on the hardware configuration of the machine:

root@byrev:/# sudo lshw -class network -short
H/W path Device Class Description
==============================================================
/0/100/1.2/0.2/6/0 enp8s0 network Realtek Semiconductor Co., Ltd.
/0/100/1.2/0.2/7/0 enp9s0 network RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

2) using lspci , utility for displaying information about PCI buses in the system and devices connected to them:

root@byrev:/# lspci | grep Ethernet
08:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. Device 8161 (rev 15)
09:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 16)

3) usgin find (search for files in a directory hierarchy) , displays only details about physical network interfaces:

root@byrev:/# find /sys/class/net -type l -not -lname '*virtual*' -printf '%f\n'
enp8s0
enp9s0

4) using ls (list directory contents), find only physical network interfaces:

root@byrev:/# ls -d /sys/class/net/*/device | cut -d/ -f5
enp8s0
enp9s0

or with driver detail:

root@byrev:/# ls -l /sys/class/net/*/device/driver/module | cut -d/ -f5,13 | sed 's?/? -> ?'
enp8s0 -> r8169
enp9s0 -> r8169

or with more data

root@byrev:/# ls -l /sys/class/net/ | grep -v virtual
total 0
lrwxrwxrwx 1 root root 0 Oct 16 19:10 enp8s0 -> ../../devices/pci0000:00/0000:00:01.2/0000:02:00.2/0000:03:06.0/0000:08:00.0/net/enp8s0
lrwxrwxrwx 1 root root 0 Oct 16 19:10 enp9s0 -> ../../devices/pci0000:00/0000:00:01.2/0000:02:00.2/0000:03:07.0/0000:09:00.0/net/enp9s0

5) using ip , show / manipulate routing, devices, policy routing and tunnels:

root@byrev:/# ip link | grep BROADCAST
2: enp8s0: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
3: enp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default

6) using ifconfig, configure a network interface (it is no longer used frequently, it has been replaced by ip):

root@byrev:/# /sbin/ifconfig -a | grep BROADCAST
enp8s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
enp9s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

These were the most used linux commands to find out details about network cards attached to a system.

Good luck with your work !

Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *