I am using VMware vCenter 5.1 to manage my servers. I would like to deploy some virtual machines via some VM templates and ask vCenter to assign IP address for these VM automatically. But it didn't work and network is not properly configured for VM I deployed, and I have no idea what went wrong here.

Here is what I did. I created a network protocol profile with an IPv4 IP pool and associated it with my network called "VM network". And I created a VM with "vApp Options" enabled. In the "vApp Options" of "Authoring" section, IP allocation scheme is set to "OVF environment", and in the "Deployment" section, "IP allocation is set to "Static IP Pool". And I created a vApp to use the "VM network", and used the VM I created previously as template to create a new VM in the vApp. My VM is a CentOS 6.4 guest with latest VMware tools installed and running.

The problem is when I created a VM in the vApp, its network adapter is not correctly set up (/etc/sysconfig/networking-scripts/ifcfg-eth0 contains incorrect Mac address and eth0 was not up) and no IP was assigned to it.

My question is how can I configure my VM/VMware vCenter to function together so that vCenter will assign static IP address from IP pool to new VMs I deploy? Thanks.


The issue you're running into is that MAC addresses must be unique so when a machine is cloned the mac addresses are regenerated. Unfortunately reconfiguring your network config files to reflect the new MAC is not something that vmware tools takes care of. Additionally, CentOS will have seen that there is already an eth0 interface and put the new MAC on a new eth1 interface.

This vmware KB has your issue: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2002767

The fix can be easily scripted and I'm sure access to vcloud automation center or a similar service would facilitate that.

A simple first boot type script that could take care of it would do the following:

  • Find the new MAC that was generated (will be configured as eth1 if the VM only has one adapter)
  • Replace the MAC in ifcfg-eth0 with the MAC found in ifcfg-eth1
  • Remove 70-persistent-net.rules
  • Reboot the VM

Script example below:


#Find the MAC that was generated for the clone (assumes only one network adapter added to the VM)
NEW_MAC=`/sbin/ifconfig eth1 |grep -i hwaddr |awk {'print $5'}`

#Replace the MAC in the eth0 file 
/bin/sed -i "s/HWADDR.*/HWADDR=$NEW_MAC/" /etc/sysconfig/network-scripts/ifcfg-eth0

#Delete the net rules file
/bin/rm /etc/udev/rules.d/70-persistent-net.rules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.