How can I find available network interfaces?

This is in regard to linux, but if anyone knows of a general *nix method that would be good.

I booted a system yesterday with an ethernet cable plugged in. “NetworkManager” is not installed, so once it started I went to look for the name of the ethernet interface with ifconfig to start a DHCP client manually, but it did not show anything other than lo.

The NIC was listed via lspci, and the appropriate kernel driver was loaded. The system normally uses wifi, and I could remember the interface name for that was wlan0. When I tried ifconfig wlan0 up, wlan0 appeared. But the only ethernet interface names I could remember were eth[N] and em[N] — neither of which worked.

This document refers to “predictable interface names” but does not do a good job of explaining what they might be in simple terms. It does refer to a piece of source code which implies the name in this case might be deduced from the the PCI bus and slot numbers, which seems like an unnecessarily complicated hassle.

Other searching around led me to believe that this might be determined by systemd in conjunction with udev, but there are almost 100 files in /usr/lib/udev/rules.d and spending an hour trying to determine where (and if) there’s a systemd config file for this also seems ridiculous.

It would also be nice to know for certain that they are available, not just how they might be named if they are, so I can rule out hardware problems, etc. Isn’t there a simple way to find the names of available network interfaces on linux?

Asked By: goldilocks


The kernel lists them by name in /sys, both separately in (e.g.) the tree of PCI devices — although finding them there if you don’t know where they are to start with is not simple — and together via symlinks in /sys/class/net. E.g.:

> ls /sys/class/net
em1 lo wlp6so

Another example:

> ls /sys/class/net
lo p6s1 wlan0

If you are not sure which is which, you could just put them all up with either:

ifconfig [name] up 


ip link set [name] up

And then look at the (fairly clear) clues listed by ifconfig (with no arguments). The systemd source code linked from the document also refers to:

Two character prefixes based on the type of interface:
 *   en -- ethernet
 *   sl -- serial line IP (slip)
 *   wl -- wlan
 *   ww -- wwan

Although in one of the cases above (p6s1) there is no prefix.

Answered By: goldilocks

The simplest method I know to list all of your interfaces is

ifconfig -a


If you’re on a system where that has been made obsolete, you can use

ip link show
Answered By: Elliott Frisch

I always do cat /proc/net/dev it’s simple and easy to memorize

Answered By: Mohammad Rafiee

ifconfig = Solaris
ipconfig = Windows
ip = Linux

That I know, but am certainly open to additions and corrections.

Answered By: Mick Myhera

When there is no ifconfig, ip available in the system one way that helped me getting IP address on Ubuntu was:

hostname -i

As pointed out in the comments, this mechanism relies on DNS hostname reolution and will not provide authorative results for all available network interfaces.

Still, this command might be helpful in troubleshooting scenarios with containers (Docker, LXC), where system tools are often not available. And at least in some cases it shows container IP which might be helpful depending on your goal.

Answered By: Sergey Shcherbakov
ip -br a

short and easy to remember thanks to a silly clothing mnemonic.

prints something like:

lo               UNKNOWN ::1/128 
enp0s32f6        DOWN           
wlp0s10f3        UP    ge80::f074:13c4:50e1:41a8/64 
docker1          DOWN  
Answered By: naugtur