Identify hardware network interfaces.
List network devices.
$ sudo lshw -class network -sanitize
*-network description: Ethernet interface product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:03:00.0 logical name: enp3s0 version: 15 serial: [REMOVED] size: 1Gbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.15.0-33-generic duplex=full firmware=rtl8168h-2_0.0.2 02/26/15 ip=[REMOVED] latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s resources: irq:16 ioport:4000(size=256) memory:a1204000-a1204fff memory:a1200000-a1203fff *-network DISABLED description: Wireless interface product: RTL8822CE 802.11ac PCIe Wireless Network Adapter vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:04:00.0 logical name: wlp4s0 version: 00 serial: [REMOVED] width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless configuration: broadcast=yes driver=rtw_8822ce driverversion=5.15.0-33-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11 resources: irq:141 ioport:3000(size=256) memory:a1100000-a110ffff
List network devices using JSON output format.
$ sudo lshw -class network -sanitize -json
[ { "id" : "network", "class" : "network", "claimed" : true, "handle" : "PCI:0000:03:00.0", "description" : "Ethernet interface", "product" : "RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller", "vendor" : "Realtek Semiconductor Co., Ltd.", "physid" : "0", "businfo" : "pci@0000:03:00.0", "logicalname" : "enp3s0", "version" : "15", "serial" : "[REMOVED]", "units" : "bit/s", "size" : 1000000000, "capacity" : 1000000000, "width" : 64, "clock" : 33000000, "configuration" : { "autonegotiation" : "on", "broadcast" : "yes", "driver" : "r8169", "driverversion" : "5.15.0-33-generic", "duplex" : "full", "firmware" : "rtl8168h-2_0.0.2 02/26/15", "ip" : "[REMOVED]", "latency" : "0", "link" : "yes", "multicast" : "yes", "port" : "twisted pair", "speed" : "1Gbit/s" }, "capabilities" : { "pm" : "Power Management", "msi" : "Message Signalled Interrupts", "pciexpress" : "PCI Express", "msix" : "MSI-X", "vpd" : "Vital Product Data", "bus_master" : "bus mastering", "cap_list" : "PCI capabilities listing", "ethernet" : true, "physical" : "Physical interface", "tp" : "twisted pair", "mii" : "Media Independent Interface", "10bt" : "10Mbit/s", "10bt-fd" : "10Mbit/s (full duplex)", "100bt" : "100Mbit/s", "100bt-fd" : "100Mbit/s (full duplex)", "1000bt-fd" : "1Gbit/s (full duplex)", "autonegotiation" : "Auto-negotiation" } }, { "id" : "network", "class" : "network", "disabled" : true, "claimed" : true, "handle" : "PCI:0000:04:00.0", "description" : "Wireless interface", "product" : "RTL8822CE 802.11ac PCIe Wireless Network Adapter", "vendor" : "Realtek Semiconductor Co., Ltd.", "physid" : "0", "businfo" : "pci@0000:04:00.0", "logicalname" : "wlp4s0", "version" : "00", "serial" : "[REMOVED]", "width" : 64, "clock" : 33000000, "configuration" : { "broadcast" : "yes", "driver" : "rtw_8822ce", "driverversion" : "5.15.0-33-generic", "firmware" : "N/A", "latency" : "0", "link" : "no", "multicast" : "yes", "wireless" : "IEEE 802.11" }, "capabilities" : { "pm" : "Power Management", "msi" : "Message Signalled Interrupts", "pciexpress" : "PCI Express", "bus_master" : "bus mastering", "cap_list" : "PCI capabilities listing", "ethernet" : true, "physical" : "Physical interface", "wireless" : "Wireless-LAN" } } ]
Extract hardware device names.
$ sudo lshw -class network -sanitize -json | jq --raw-output '.[].logicalname'
enp3s0 wlp4s0
Extract hardware device names and display IP addresses.
$ sudo lshw -class network -sanitize -json | jq --raw-output '.[].logicalname' | xargs -I{} ip --brief addr show dev {}
enp3s0 UP 172.16.151.200/21 fe80::b0d:5d9a:7083:fced/64 wlp4s0 DOWN