Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
In the question you state that you used ip link but then you accept an answer that suggests ip link show which does the exactly same thing. Why? –  Pavel Šimerda Apr 23 at 16:07
    
@PavelŠimerda You're right. I might have in fact used ip route -- I wrote this question the next day after the problem was solved (see my own answer); I'm not in the habit of using ip and don't appreciate the excessively spartan man pages, so I probably gave up on it after one try and started going through /sys, since I knew the kmod was loaded, etc. and this was more straightforward to me. I'll remove that completely from the question. –  goldilocks Apr 24 at 12:39
    
The manual pages for iproute2 are quite good nowadays, I guess you're using and older version of the package. –  Pavel Šimerda Apr 25 at 17:12

2 Answers 2

up vote 7 down vote accepted

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

ifconfig -a

EDIT

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

ip link show
share|improve this answer
1  
If I'd just looked at the man page! Be interesting to know if ip has a parallel, since supposedly ifconfig is being "obsoleted" in favour of that (IMO) more obtuse and less user friendly command. –  goldilocks Apr 18 at 15:05
    
@TAFKA'goldilocks' I haven't heard that. Are you sure? The commands serve different purposes. ip - show / manipulate routing, devices, policy routing and tunnels and ifconfig - configure a network interface –  Elliott Frisch Apr 18 at 15:07
    
First thing in my man ifconfig: "NOTE This program is obsolete! For replacement check ip..." That may be specific to linux. Hopefully they have to retain it for backward compatibility with something. –  goldilocks Apr 18 at 15:09
    
@TAFKA'goldilocks' I'm on 12.04 ubuntu. Things do change from time to time. Try ip link show –  Elliott Frisch Apr 18 at 15:10
1  
ifconfig deprecated? come on. This command has been around for like 30 years. –  Michael Martinez Apr 18 at 18:02

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 

Or:

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 Freedesktop.org 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.