LKBEN11688: How to list all network interfaces on linux.
Symptom
You have multiple network cards in your server and need some information about these.
Cause
e.g. Which network interface is currently active.
Solution
To list all your network interfaces you can use the ip command.
ip link show
The command will list local loopback, all the interfaces and also the virtual bridges.
lo = Loopback interface
eth0 = normal network card
wlan0 = a wireless network interface
ppp0 = point to point protocal
virbr0 = virtual bridge
On some servers you will not find the notation of eth0, eth1 etc. They will have names like enp2s0f0, enp2s0f1, enp6s0f0, enp6s0f1, ...
Here an example output:
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: enp2s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 00:25:90:9a:3b:dc brd ff:ff:ff:ff:ff:ff
3: enp2s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 00:25:90:9a:3b:dd brd ff:ff:ff:ff:ff:ff
4: enp6s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 28:80:23:df:b3:50 brd ff:ff:ff:ff:ff:ff
5: enp6s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 28:80:23:df:b3:54 brd ff:ff:ff:ff:ff:ff
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:d0:7f:1d brd ff:ff:ff:ff:ff:ff
Another possibility is to use the nmcli command:
nmcli device status
DEVICE TYPE STATE CONNECTION
enp6s0f1 ethernet connected Wired connection 4
virbr0 bridge connected (externally) virbr0
enp2s0f0 ethernet unavailable --
enp2s0f1 ethernet unavailable --
enp6s0f0 ethernet unavailable --
lo loopback unmanaged --
nmcli connection show
DEVICE TYPE STATE CONNECTION
enp6s0f1 ethernet connected Wired connection 4
virbr0 bridge connected (externally) virbr0
enp2s0f0 ethernet unavailable --
enp2s0f1 ethernet unavailable --
enp6s0f0 ethernet unavailable --
lo loopback unmanaged --
This will give you a nice overview of your network devices and if they are active or not.
Yet another interesting command is tcpdump:
tcpdump --list-interfaces
1.enp6s0f1 [Up, Running, Connected]
2.any (Pseudo-device that captures on all interfaces) [Up, Running]
3.lo [Up, Running, Loopback]
4.enp2s0f0 [Up, Disconnected]
5.enp2s0f1 [Up, Disconnected]
6.enp6s0f0 [Up, Disconnected]
7.virbr0 [Up, Disconnected]
8.bluetooth-monitor (Bluetooth Linux Monitor) [Wireless]
9.nflog (Linux netfilter log (NFLOG) interface) [none]
10.nfqueue (Linux netfilter queue (NFQUEUE) interface) [none]
11.dbus-system (D-Bus system bus) [none]
12.dbus-session (D-Bus session bus) [none]
Disclaimer:
The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!About the Author
Author:
- Keskon GmbH & Co. KGWim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.
Latest update: 20.11.2023