Hi friends, recently I got a chance to change the network interface to eth0 in a centos server.

It is very simple and I have made a shell script to automate this task.  You can also do the manually, please refer the url “http://mylinuxdiary.com/?p=192” for better understanding.

Please copy the below script and paste it in a file and give execute permission and run.

#! /bin/bash

# This program is distributed in the hope that it will be useful.

#developed by Nithin Thomas
sed -i ‘s/rhgb quiet/ rhgb quiet net.ifnames=0 biosdevname=0/’ /etc/sysconfig/grub #disabling the predictable naming
echo “regenerate GRUB configuration”
grub2-mkconfig -o /boot/grub2/grub.cfg
value=`ifconfig | grep eth | awk ‘{print $1}’`
mv /etc/sysconfig/network-scripts/ifcfg-$value /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i “s/$value/ eth0/” ‘/etc/sysconfig/network-scripts/ifcfg-eth0’
echo “system need a reboot”
echo “shall we reboot the system”
echo “press y for reboot and N no reboot”
read data
if [ “$data”= y ]; then
reboot
else
echo “aborted”
fi

Leave a Reply

Your email address will not be published. Required fields are marked *