Rename Network interface without rebooting
Quote from moshe on 14/08/2022, 2:56 pmProblem
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 upmv /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
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 upmv /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:
Quote from moshe on 14/08/2022, 2:59 pmWith 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
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