Do you know how to check the IP address of a Linux server?
“Of course!”, you say, and you type this:
$ ifconfig eth0
Not anymore! Both the command
ifconfig and the interface name
eth0 have been obsolete for a few years now.
However, many organizations still use something like Red Hat Enterprise Linux 6, where the old commands and interface names work.
Red Hat officially released RHEL 7 in June 2014. Its third birthday is approaching, and organizations are finally moving to it or derivatives like CentOS, Oracle Linux, or Scientific Linux. It’s time to learn the new names and commands.
This week I’ll explain the interface names, including why the change is helpful. Next week I’ll explain the new commands.
eth1, and so on?
If you have multiple Ethernet interfaces on current hardware, you can’t predict the order in which the system detects them. This includes wired Ethernet devices
eth[0-9]* and wireless interfaces
Some time ago I wrote about systemd, a new master process to control the system state and all services on Linux. Its philosophy is to start everything simultaneously, letting services work out their order dependencies by communicating over sockets. That gets the system up and running quickly, but we can’t predict the precise order of events.
BIOS firmware was replaced by UEFI (or Unified Extensible Firmware Interface) several years ago. Unless you are using a very old motherboard, you should have what’s needed. Use the
biosdecode command and look for SMBIOS version 2.6 or later.
You will also need systemd/udev version 197 or later, they came out a number of years ago.
Yes, if you want the old unpredictable names you can pass
net.ifnames=0 to the kernel at boot time. But why?
Learning Tree’s Linux server administration course describes SysFS. It appears as a file system hierarchy below
/sys, but that’s a human-friendly representation of kernel data structures. This includes the hardware details of detected interfaces including Ethernet, SATA, SCSI, and more.
The kernel detects device hardware locations in terms of PCI bus number, slot number, and device number. That will not change unless you unplug it and move it to a different expansion slot. The new names are based on these physical parameters, and so they do not change from one boot session to the next.
What are these names?
en02, … and
Firmware-numbered interfaces embedded on the motherboard.
Firmware-numbered PCIe hotplug interfaces.
At PCI bus address 02:00.0.
A card plugged into PCIe slot #7.
When I first looked into this, I was frustrated as I could never predict a network device name in advance.
Would the embedded interface be
Would a card plugged into a slot be
Then I realized that I don’t care!
I can’t see any benefit of predicting a device name in advance. Shut the system down, plug in the new card, and start it up. Then list the network devices:
$ ls /sys/class/net
Those names will always be the same until you move an expansion card.
If you want to dig deeper, try these commands on your system:
$ ls -l /sys/class/net [... see the links to physical addresses ...] $ dmesg | egrep --color -C 2 'eth[0-9]|e[nm][0-9]|p[0-9][ps][0-9]|wlan|wl[0-9]|wlp[0-9]' [... see the kernel discovering devices and the udev daemon assigning consistent names ...]
Getting away from the overly generic names like
eth0 brings Linux more in line with other UNIX family operating systems. I’m writing this on an OpenBSD system, where the Ethernet interface is
re0 as it was detected by the
re Realtek kernel module. Replace it with an Intel-based device, and it’s
ie0. Does anyone else remember hearing of “Happy Meal Ethernet” on UltraSPARC platforms? That name comes from the days of the
hme kernel module in Solaris discovering and naming interface
This is really no big deal. Configuration on Red Hat or a similar system goes in a file named
ifcfg-name in the directory
/etc/sysconfig/network-scripts/, the same as always.
The software loopback device is still
lo, and everything else is a wired or wireless network connection.
Come back next week to learn how the
ip command now does almost everything. We can no longer trust our old friends
Interface name changes are no big deal. But command syntax and semantics — that’s huge!