Ok, so you’ve installed a CentOS server into a Parallels Virtual Machine. If you experiment with clones or templates then it shouldn’t take you very long to notice that networking stops working. Let’s find out the cause of the problem, fix it, then speculate about what is going on.
# ifconfig reports only a lo/Loopback interface
# ifconfig -a reports an inactive eth0 or eth1/Ethernet interface, meaning it is there but down.
If you still have an eth0 interface, just try # ifup eth0 and see how that works.
In my case I have an eth1 and # ifup eth1 fails with a message about missing configuration details. Hmmm…
# ls /etc/sysconfig/network-scripts/ shows the presence of ifcfg-lo and ifcfg-eth0 but no ifcfg-eth1. Ah-ha! It’s failing to initialise because it doesn’t have a configuration profile.
Let’s make use of the existing eth0 profile.
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
But we need to make some changes.
# nano /etc/sysconfig/network-scripts/ifcfg-eth1
Change the DEVICE and HWADDR entries.
- DEVICE should be “eth1”
- HWADDR should be your VM’s MAC address
- Click on the configuration cog in the bottom-right corner of your window, select the Hardware tab, then Network 1
- If the MAC address is different to what is in the config file, you need to type the address in carefully (at this stage since you don’t have networking, you probably haven’t installed Parallels Tools either, so copy and paste won’t work)
CTRL-X then Y then ENTER will close the editor and save changes.
# ifup eth1 should now bring up the interface.
# ifconfig should show that your nyetwork is now working.
So, why did it ‘break’?
What seems to happen is that, whenever you clone a VM or turn it into a template and instantiate it, Parallels allocates a new and different interface for networking along with a different MAC address.
The new MAC address I understand because consider what would happen if you ran both the original and cloned VMs at the same time. You would have two (virtual) machines on the same (virtual) network with the same MAC address and that is just not a good idea. So to prevent this from happening each clone/instance gets a different MAC address. Fair enough.
I’m not sure about why the interface needs to change from eth0 to eth1, eth2 and so on, as that is at least one abstraction level higher than MAC addresses. If I get a chance I might set up another CentOS VM and run two VMs with the same ethernet interface at the same time to see if there is any conflict. If so then interfaces may be a resource which needs to be shared between all running VMs and that would explain why they change as well.
tl;dr: Remember to duplicate and update your ethernet interface configuration profile every time you clone or instantiate a VM and you’ll be fine.