Available Network Interfaces

This page is about seeing what network interfaces were detected by the operating system, and for systems with multiple network interfaces, determining which physical network circuitry corresponds to each logical interface identifier (such as a name).

Simply showing a list of available network identifiers may effectively point out what is available. More details about detecting hardware are available in another section.

Identifiers in Unix
Commands to run

The following works in OpenBSD and presumably other systems, and is based on code found at UnixTechnics.org Docs:OpenBSD:System sysinfo commands:

echo ; ifconfig -Aa | awk '$2 ~/flags/ { print substr($1, 0, length($1) -1) }' | xargs echo -n ; echo

However, some systems might not have awk while fewer others may not have xargs, so that elaborate command may not work.

Use “ ifconfig -Aa ”. Some variations, particularly with newer ifconfig code, may not need quite as much for parameters: “ ifconfig -A ” or “ ifconfig -a ” or even simply “ ifconfig ” with no parameters at all.

An example of an interface which probably does exist, but which probably does not need to be manually configured with an IP address, is a loopback interface named lo0. If the card does not seem to be visible from ifconfig, then locate it in the output of dmesg or some other commands that detect hardware. (It may be that the hardware was detected, but it is not currently being supported as a network interface. A command to enable networking support might help.)

Running “ route show | $PAGER ” or its equivilent command, “ netstat -nr | $PAGER ”, may also show interface names in an “Iface” column.

(This is assuming that PAGER is set. That may be an unsafe assumption: see setting operating system environment variables to assign PAGER to either less or, in the unlikely case of less being unavailable, set PAGER to more. If even that is causing problems, just entirely take off the “ | $PAGER ” from the sample command lines.)

ip link show
may work in Debian
Interface identifiers of Ethernet cards in Linux

eth0, eth1, etc.

Note: In BackTrack (version 3?), the interfaces may not ready be visible when using a command line tool such as ifconfig. They may, however, work normally after being enabled in a graphical interface. (Why? Unconfirmed. Perhaps need to run “ /etc/init.d/networking start ”? (The command may also support a “ restart” command).

Interface identifiers of network cards in OpenBSD

“Devices are named by driver, not by type. For example, there are no eth* devices.” (This quoted text comes from OpenBSD FAQ 9: Migrating to OpenBSD.)

The drivers typically have names that are two to four characters long. In general, the first available card that uses a specific driver will be named after that driver and have a number, starting with zero, placed after the driver name.

A notable exception is for NE2000 cards and cards that are compatible with a “NE2000 and compatible 10/100 Ethernet device” (as described by the man page for the driver of those cards). (The main reason this may be noteworthy is that there have been quite a few cards made to be compatible with an NE2000 card. However, since they were primarily popular on older systems, the notability may decrease as time goes on.) OpenBSD's man page for the “ne” NE2000 (compatible) driver (“Synopsis” section) shows that the names ne0, ne1, and ne2 are used for devices that are using specific I/O port numbers and IRQ numbers. (Those I/O port numbers and IRQ numbers are documented on that man page as well as OpenBSD's INSTALL.i386 file which is part of the collection of installation files for OpenBSD/i386. This may also be seen in the kernel configuration file (e.g. one of the “text” hyperlinks from OpenBSD/i386 GENERIC kernel configuration file) in the sections called “Networking devices” about 7 lines from the header.) If a card is detected but which is not using those reserved I/O ports and/or IRQ numbers, the first detected card may be given a name of ne3. (The second detected card may be given a name of ne4, etc.) (Verifying this further might be doable by changing the I/O port address used by the virtual machine.)

So, for a Qemu virtual machine using NE2000 hardware running OpenBSD, the interface is probably ne3 rather than if0. However, if the Qemu machine is using the E1000 network circuitry, then the available interface name will likely be em0. (Some further discussion on Qemu NIC types is available: Windows 98 guide: disussing Qemu network models.)

Those who would be interested in seeing some additional documentation from a more official source may see, OpenBSD FAQ 6: section called “Identifying and setting up your network interfaces” (section 6.2.1, under the OpenBSD FAQ 6: Network configuration (section 6.2)) discusses the matter further.

Additional hints/methods for determining the name of a network device may be to see what /etc/hostname.* files exist, reviewing the firewall rules (very possibly in /etc/pf.conf), or looking through the output of dmesg. (These probably will not work better/easier than just using ifconfig, but may simply be additional options.)

A generic network driver, which is “if”, may be used for some documentation. For example, the /etc/hostname.* configuration files are discussed by the man page for OpenBSD's /etc/hostname.* files, which can be used by looking up the OpenBSD manual page for “hostname.if” (/etc/hostname.* files) (either on the web page, or by running “ man hostname.if ”).

For the list of possible network devices that the kernel tries to automatically detect, check out the kernel configuration file (e.g. one of the “text” hyperlinks from OpenBSD/i386 GENERIC kernel configuration file) in the sections called “Networking devices” and “Wireless network cards”. It seems that a list of network drivers that the kernel will attempt can be seen by the *phy* entires in the “list” command of the program called config. Some sample (and perhaps old) (and definitely truncated, where the text says “[...snip...]”) output is visible on the OpenBSD FAQ 5: section on using config to change a kernel.

Microsoft Windows

NICs may be most frequently referred to by names. The names show up in Device Manager, in the Network Control Panel Applet, and in the output of ipconfig.

The names may also be seen by running “ WMIC nic get /ALL ”. To trim down the output a bit, perhaps use:

WMIC nic get AdapterType,Description,InterfaceIndex,MACAddress,Name,NetConnectionID,NetEnabled,PhysicalAdapter,PNPDeviceID,ProductName,ServiceName | find "TRUE" >> output.txt

(Even that output will probably show more information than what is typically useful.)

(Actually, that sample command was written that way just to point out that output can be sent to the main terminal simply by removing the redirection symbols. Another way to create a file from WMIC's output, if that is actually desired, is generally to use the /OUTPUT:output.txt syntax. This may be mentioned in the section on Microsoft WMI: WMIC output.)

[#nicidmsw]: Interface “index” identifiers in Microsoft Windows

Interface “index” identifiers may be used in some cases, such as using some netsh commands. Another example is using ping -6 with a network address that starts with “fe80:”.

The network identifiers can be shown by using “ netstat -nr ” and the functionally equivilent “ route print ”. (Note that although there are similar commands in Unix, “ netstat -nr ” and the similar route command, which might be “ route show ”, do not show interface identifiers like they do with Microsoft Windows. So although using “ netstat -nr ” is a cross-platform method of obtaining routing information, these commands do not represent a cross-platform method, that also works in Unix, for obtaining the NIC name/index.) Output will scroll off: This may be circumvented by adding a “  | more ” to the end of the command line.

The network identifiers can be shown by using “ netsh interface ipv4 show interfaces ”. The numeric identifier for each identifier is in the left-most column, which is labelled “Idx”. The name of the interface is, unsurprisingly, under the column which is labelled “Name”. (The “Name” column is the fifth column.)

Also unsurprising, a similar command also works: “ netsh interface ipv6 show interfaces ”. More surprising, those lists may not match: In at least one system, the “netsh interface ipv6 show interfaces” would show a couple of extra devices (which had a state of disconnected). (These devices had names of “Local Area Connection* 6” and “Local Area Connection* 7”. Yes, the * shown here was literal text.)

Idx  Met   MTU   State        Name
---  ---  -----  -----------  -------------------
  1   50 4294967295 connected Loopback Pseudo-Interface 1
 10   20   1500  connected    Local Area Connection
 11   10   1500  disconnected  Local Area Connection 2

These names might also be seen as the InterfaceIndex using “ WMIC nic get /ALL ”.

The interface identifiers can also be shown with “ WMIC NICCONFIG WHERE IPEnabled='True' GET Index,Caption

Another variation that works is “ netsh interface show interface ” (or “ netsh int show int ”). This variety will nicely show which cards have a connection.

Other commands

SystemInfo may end with a section called “Network Card(s)”. Other options may include “ WMIC NIC get ” and “ WMIC NICCONFIG get ”.

MAC addresses

Indications of adapters may also exist using the getmac command (in Windows XP and newer). See: Windows XP Documentation on the getmac command.

Cisco IOS

After logging into Cisco IOS, a process for determining the available NICs is described by the Cisco IOS: basic usage guide.