I would like to find a way to have the HWADDR line in the ifcfg-eth0 script verify/update itself on-boot in case it changes when a clone or copy of the VM occurs. Is there a way to do so? In CentOS 6, removing the HWADDR line from the ifcfg-eth0 script made it much more dynamic, but I have yet to find a way to keep ifcfg-eth0 from changing back to ifcfg-eno1677776 without the HWADDR line in CentOS 7. Thanks in advance for the help!
I am running a CentOS 7.2.1511 virtual machine via VMware Workstation. By default CentOS 7 got rid of the eth0 naming convention of its network scripts and is now configured to use network scripts named ifcfg-eno1677776 or something similar. I have software that heavily relies on the eth0 naming scheme. So I have re-configured my ifcfg-eno1677776 script by:
Modifying ifcfg-eth0 to be (got HWADDR from
BOOTPROTO=dhcp NAME=eth0 DEVICE=eth0 ONBOOT=yes NM_CONTROLLED=no HWADDR=00:0c:29:d6:d2:65
Added net.ifnames=0 to the end of the GRUB_CMDLINE_LINUX line in the
Reboot and run ifconfig (and celebrate!):
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.176.15.148 netmask 255.255.252.0 broadcast 10.176.15.255 inet6 fe80::20c:29ff:fed6:d265 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:d6:d2:65 txqueuelen 1000 (Ethernet) RX packets 2141073 bytes 749959853 (715.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 65237 bytes 35352127 (33.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Each time I boot, this eth0 interface remains. However, this VM is to be distributed between team members and eventually delivered to customers. This is where the problem arises. VMware is great in that you can clone a snapshot of a VM for distribution, but this changes the MAC address of the VM.
You must run
grub2-mkconfig -o /boot/grub2/grub.cfg after making the change @larsks recommended below for it to work. Worked for me!