nameif
Assign names to network interfaces
SYNOPSIS
nameif [ -s ] [ config_file | config_directory ]
Example usage:
nameif /etc/sysconfig/network-scripts/ifcfg-eth0
nameif -s /etc/sysconfig/network-scripts/
PARAMETERS
-s
Scan a specified directory for network configuration files (e.g., ifcfg-* files) and apply naming rules based on their contents. If no directory is specified, it typically defaults to a standard location like /etc/sysconfig/network-scripts/.
config_file
Process a single network configuration file. nameif will extract the hardware address (HWADDR) from this file and attempt to rename the corresponding network interface based on its MAC address.
config_directory
Process all network configuration files within the specified directory. This is typically used with the -s option.
DESCRIPTION
nameif is a utility designed to ensure that network interfaces on a Linux system are assigned consistent device names (e.g., eth0, eth1) across reboots, regardless of the order in which the kernel detects them. It achieves this by matching the network interface's MAC address (hardware address) to a HWADDR entry specified in a network configuration file, typically found in /etc/sysconfig/network-scripts/ifcfg-*.
Historically, systems sometimes faced an issue where network interfaces would swap names (e.g., what was eth0 might become eth1 after a reboot) if the kernel initialized them in a different order. This could break network configurations that relied on specific device names. nameif was developed to solve this problem by providing a mechanism to enforce persistent naming. Although it was a crucial tool in older Linux distributions (like Red Hat Enterprise Linux 5 and 6), its functionality has largely been superseded by more modern and robust mechanisms such as udev rules and systemd.link files, which handle device naming and persistence directly within the kernel device manager.
CAVEATS
Primarily used in older Linux distributions (e.g., RHEL/CentOS 5, 6).
Largely deprecated in modern systems due to the adoption of udev and systemd.link for consistent network device naming.
Requires network configuration files to contain a HWADDR entry for proper functioning.
May require root privileges to execute and modify interface names.
INTERACTION WITH IFCFG FILES
nameif relies heavily on the HWADDR directive within network configuration files, such as those found in /etc/sysconfig/network-scripts/ifcfg-
BOOT-TIME USAGE
Historically, nameif was often invoked early in the boot process (e.g., by init scripts or udev rules) to ensure network interfaces were correctly named before network services were brought online. This guaranteed that ifcfg-eth0 always configured the intended physical network card.
HISTORY
The nameif command was part of the net-tools or initscripts package, which provided essential networking utilities for Linux systems. Its development was driven by the need for persistent and predictable network interface naming during system boot, a common challenge before the widespread adoption of dynamic device management systems like udev. While critical for maintaining network stability in older environments, its importance has diminished significantly with the evolution of Linux's device management architecture.