The above short tutorial shows how to rename the default Network Interface Cards (NIC) label with your own names instead of eth0, eth1..etc. This may be useful for those who have multi number of NIC cards listening on different networks. Setting up your own names may helpful for easy identification.
Though various tutorials are available online, i found the following steps are easier and error free and also works well in various Linux Distributions. The following steps how to rename the eth0 using the nameif command (comes with net-tools package, you can install it using yum install net-tools) and how to setup it on boot.
Use the ifconfig command to find the current interace names and the hardware address(HWaddr). An example screen-caps below.
Edit or create a new file (/etc/mactab) using your favorite editor and add the following lines(i have renamed eth0 to gnutoolbox in the below example so make sure you are adding your own name instead of gnutoolbox).
# The 00:11:D8:xx:xx:xx is the HWaddr
Now run the nameif command
- # nameif
You will be getting the following error
cannot change name of eth0 to gnutoolbox: Device or resource busy
So, first take the interface down, then rename it.
Warning : If you have connected the server using ssh remotly you will lose the connection (you need to do this on TTY)
- # ifconfig eth0 down
# ifconfig gnutoolbox up
The output will look below like the below screen-caps.
Making the changes permanent at boot time
Nameif needs to be run early in the boot cycle, before the network interfaces are brought up. This means adding it to /etc/rc.d/init.d/network . Edit the start of the file as follows:
# Begin $rc_base/init.d/network – Network Control Script
# Based on ethnet script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans – [email protected]
case “$1” in
if [ -e /etc/mactab ]
# if /etc/mactab exists then set up the named interfaces
for file in $(grep -il “ONBOOT=yes” $network_devices/ifconfig.*)
This ensures that nameif is run with /etc/mactab, if that file exists.
Now go to /etc/sysconfig/network-scripts directory and rename /etc/sysconfig/network-scripts/ifcfg-eth0 interface file to ifconfig.yourname and edit it so that DEVICE=yourname.