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:
#!/bin/sh
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
fi
In my own lab I would personally enable guest customization and have this script as part of the template by default.