browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

NIC label issue when deploying CentOS 6.x VMs with vCloud Director

Posted by on October 3, 2013

I came across a small issue relating to the the labelling of the primary NIC (eth0) inside a deployed VM.

It seems that due to the templating and then deployment of the VM the Linux hardware detection process sets the new NIC as eth1. This is due to the new MAC generated at instantiation, normal behaviour.

For the most part this does not affect the VM’s ability to access the network however there may be times when multiple NICs are required or for neatness it is desirable to have the NIC labelling starting at eth0.

To automatically fix this during the initial power of the deployed VM, enable Guest Customization and insert this script into the Customization Script section:

set -x
if [ x$1 == x”postcustomization” ]; then
rm -rf /etc/udev/rules.d/70-persistent-net.rules
sed -i “s/eth1/eth0/g” /etc/sysconfig/network
mv -f /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i “s/eth1/eth0/g” /etc/sysconfig/network-scripts/ifcfg-eth0
/etc/rc.d/init.d/network restart

In my own lab I would personally enable guest customization and have this script as part of the template by default.

Leave a Reply