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)
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.
8 thoughts on “Enable Networking on CentOS Server Parallels VM”
Thank you. That was very helpful.
Thanks you very much for the tutorial but it doesn’t seems to be working on my virtual machine. I followed everysingle steeps. I dont have problem any where but at the end when i try to enable eth1 with command ifup eth1 command it says Device eth1 doesnt seems to be present though i can see eth1 when i give ls /etc/sysconfig/network-scripts/ command. Any help please struggling to update my centos 6.3 since day before yesterday and I am completely stuck. Hopping to hear from you soon. Many thanks
Remember to use # ifconfig -a to find out which interface is present but not active. It is usually eth1, but can be eth2, eth3, eth4… depending on how many virtual machines you have.
Whatever ethX the above command shows as inactive is the one you use for the rest of the steps. So make sure /etc/sysconfig/network-scripts/ifcfg-ethX exists, has ethX in the DEVICE field and the right MAC address (which changes every single time you make a new virtual machine).
First of all, I would like to thank you for your valuable time answering me. Well I am a new to Linux. I am trying to learn centos using virtual box. I have installed oracle virtual box on my system. I have installed 3 cents version 6.3 and I am following a book (The definitive guide to centos) but now I seems to be tucked completely… all I want to do is yum update but every-time I do it gives me following error
[root@localhost ~] yum update
Loaded ;lugins: fastestmirror, Security
Loading mirror speeds from cached host file
Could not retrieve mirrorlist http://mirrorlist.centos. Org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 – “Couldn’t resolve host ‘mirrorlist.centos.org’”
Error: Cannot find a valid baseurl for repo: base
I have already spent almost 2 days to solve the problem. I went through so many web forum. It seems to be the real culprit one from your forum but nothing happening. So just wondering if you can help me to solve this problem. Many thanks
ajay, the yum update is failing because your virtual machine cannot connect to the Internet. If you can fix your networking then the update should work as well. I don’t use Virtual Box (the above guide is for Parallels) so I can’t offer specific advice for Virtual Box. Generally, though, if you edit the correct ifcfg-ethX configuration file and plug in the correct DEVICE and MAC address entries then your wired ethernet should work. Good luck!
DooD – you’re a star !
I had the same issues with virtualbox as well but following your examples and train of thought has resulted in a working setup !
Many Thanks !
I’m glad my post help nudge you in the right direction. Well done for adapting it to your particular circumstances. 🙂
You could remove /etc/udev/rules.d/70-net-persistent-rules before snapshot or template creation, and the device files for eth0 will be regenerated on reboot.