Forum Navigation
You need to log in to create posts and topics.

Rename Network interface without rebooting

Problem

User wants to rename the network interface name on cent0s7/8 without rebooting.

One of the reasons is to create network compatibility for applications like kubernetes who looks for identical hardware on all nodes

Solution

run the following commands to rename the network interface. rename and set accordingly

ip link set ens192 down
ip link set ens192 name eth0
ip link set eth0 up

mv /etc/sysconfig/network-scripts/ifcfg-{ens192,eth0}
sed -ire "s/NAME=\"ens192\"/NAME=\"eth0\"/" /etc/sysconfig/network-scripts/ifcfg-eth0
sed -ire "s/DEVICE=\"ens192\"/DEVICE=\"eth0\"/" /etc/sysconfig/network-scripts/ifcfg-eth0
MAC=$(cat /sys/class/net/eth0/address)
echo -n 'HWADDR="'$MAC\" >> /etc/sysconfig/network-scripts/ifcfg-eth0

 

Uploaded files:

With rebooting option and permanently

edit the file

/etc/sysconfig/network-scripts/ens192-ifcfg

and set the name and the device for the new name. for example: eth0

edit the file

/etc/sysconfig/network

and set GATEWAYDEV to the new name