How to Rename Ethernet Interface to eth0 in Linux on VM

Sometime you may need to change the Network Interface Name on your system. I faced issue while I was cloning a node to prepare a new node for RAC Environments on Oracle Linux 6.5.

When you clone a VM, you need to reassign the Network device means it will assign new UUID for the device and it will create new Network Interface at OS level. But For RAC, You need to set same name of Network Interface for all nodes. I got below error while was trying install GI (Grid Infrastructure) with different Network Interface Name.

Issues:

Network interface bonding status of private interconnect network interfaces - Checks if the network bonding feature, if used for private interconnect network interfaces, is configured using correct bonding mode
  Operation Failed on Nodes: [ocmdrnode1,  ocmdrnode2]  
Verification result of failed node: ocmdrnode1  Details: 
 - 
PRVG-1512 : Failed to retrieve current selection of public and private network classifications  -
Cause:  Could not retrieve the list of public and private network classifications selected in current 
configuration.  - Action:  Ensure that the configuration of public and private network classifications is done correctly during the installation process. 

IFCONFIG Output:

[grid@ocmdrnode1 ~]$ ifconfig
eth4      Link encap:Ethernet  HWaddr 08:00:27:93:85:95
          inet addr:192.168.56.110  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe93:8595/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22285 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19481 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3087167 (2.9 MiB)  TX bytes:19105687 (18.2 MiB)

eth5      Link encap:Ethernet  HWaddr 08:00:27:7B:B0:98
          inet addr:192.168.10.110  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: 2600:1700:8930:4760:a00:27ff:fe7b:b098/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe7b:b098/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24220 errors:0 dropped:0 overruns:0 frame:0
          TX packets:925 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1519758 (1.4 MiB)  TX bytes:129636 (126.5 KiB)

Change on ifcfg-eth0 & ifcfg-eth1

[root@ocmdrnode1 network-scripts]# pwd
/etc/sysconfig/network-scripts

[root@ocmdrnode1 network-scripts]# cat ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.56.110
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
UUID=879dd14c-2451-466d-94ee-357d8100baff
ONBOOT=yes
HWADDR=08:00:27:93:85:95
LAST_CONNECT=1597452404

[root@ocmdrnode1 network-scripts]# cat ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.10.110
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth1
UUID=e93c73bf-13b5-4e15-95ea-cc64c3b13d13
ONBOOT=yes
HWADDR=08:00:27:7B:B0:98
LAST_CONNECT=1597452404

I again tried to restart my network and it started this time, however, the ifconfig was still showing old one, But the configuration file eth0 was picked up.

[root@ocmdrnode1 network-scripts]# /etc/init.d/network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/4
                                                           [  OK  ]
Bringing up interface eth1:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/5
                                                           [  OK  ]
[grid@ocmdrnode1 ~]$ ifconfig
eth4      Link encap:Ethernet  HWaddr 08:00:27:93:85:95
          inet addr:192.168.56.110  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe93:8595/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22285 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19481 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3087167 (2.9 MiB)  TX bytes:19105687 (18.2 MiB)

eth5      Link encap:Ethernet  HWaddr 08:00:27:7B:B0:98
          inet addr:192.168.10.110  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: 2600:1700:8930:4760:a00:27ff:fe7b:b098/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe7b:b098/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24220 errors:0 dropped:0 overruns:0 frame:0
          TX packets:925 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1519758 (1.4 MiB)  TX bytes:129636 (126.5 KiB)

Renaming my network interface to eth0:

[root@ocmdrnode1 network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:0b:ac:fb", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b9:5f:d0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:41:b9:8c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:fd:6a:93", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:93:85:95", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:7b:b0:98", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"

After changed the /etc/udev/rules.d/70-persistent-net.rules file:

Note:::Make Sure you are renaming correct one with mapping ATTR{address} attributes.

[root@ocmdrnode1 network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:93:85:95", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:7b:b0:98", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Restart Network:

[root@ocmdrnode1 network-scripts]# /etc/init.d/network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down interface eth1:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down interface eth3:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/255
                                                           [  OK  ]
Bringing up interface eth1:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/256
                                                           [  OK  ]
Bringing up interface eth3:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/257

You need to reboot the OS / VM to see the impact on -> ifconfig command output.

After rebooted OS/System:

[root@ocmdrnode1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:93:85:95
          inet addr:192.168.56.110  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe93:8595/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:128 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9908 (9.6 KiB)  TX bytes:6327 (6.1 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:7B:B0:98
          inet addr:192.168.10.110  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: 2600:1700:8930:4760:a00:27ff:fe7b:b098/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe7b:b098/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15550 (15.1 KiB)  TX bytes:826 (826.0 b)