Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Cloning CentOS Guests - Disable MAC

Today I was scratching my head trying to figure out why my changes to the network to go from DHCP to static IP was not taking effect on my CentOS 7 guest. It turns out that the network configuration is defaulted to including the HWADDR (MAC) address as shown below:

# Generated by dracut initrd
NAME="eth0"
HWADDR=52:54:00:4D:24:AA
ONBOOT=yes
NETBOOT=yes
UUID="dd66e666-87dc-4814-a862-61b8411c2c3d"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

When you clone a guest, the new guest is given a new MAC address but your network scripts will not be automatically updated. If your guests only have 1 NIC then you can just comment the HWADDR line out and your guests will still work. Thus you can keep cloning without having to remember to update the MAC.

References

Last updated: 16th September 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch