Two VirtualBox VMs running in parallel assigned same IP

9

2

I had one VM in my VirtualBox and wanted to use it as a template/image so I cloned it. Then I launched both the original and the clone simultaneously (to simulate a server cluster for something I was working on), however, both instances were assigned the same IP address. Is this perhaps a bug in our DHCP, which I think VirtualBox uses to get IP addresses? Or perhaps something in the way I set up my VMs? Anyway, I am ultimately interested in resolving this issue so that I can two VMs of the same image concurrently.

amphibient

Posted 2013-10-07T20:47:43.607

Reputation: 1 613

On VMWare, if you started a previously used VM from a different path, it asked if you copied it or moved the VM to be able to avoid such situations... How did you clone the VM? – ppeterka – 2013-10-07T20:51:33.897

i'm afraid this is not the situation here... – amphibient – 2013-10-07T20:52:14.300

1It is possible that you copied the machine with the MAC (Ethernet) address. That is one of differences between copying and moving in VMware as mentioned by ppeterka. Could you please check the addresses? Could you also please describe how exactly did you clone the machine? – pabouk – 2013-10-07T21:12:48.700

yes, when i ran ifconfig -a, it showed the same MAC address for both (displayed as HWaddr) – amphibient – 2013-10-07T21:34:57.193

but the way i cloned it was in UI, just right-clicked the VM and hit Clone – amphibient – 2013-10-07T21:36:00.540

Answers

12

This is known as an IP conflict and can cause major headaches on the network.

You can re-initialize the MAC address of the cloned VM; that just means generate a new random one. On your cloned VM click Settings >> Network >> Advanced then click the two circular arrows to generate a new MAC. Your VM will need to be off. When it boots your DHCP server should assign the VM a different IP address.

Also FYI, when you cloned your VM you should have seen a checkbox with the words "reinitialize MAC", that would have cloned the VM and generated a new MAC instead of cloning it.

If you were curious, cloning a VM is often used to make a full backup of the VM, in this case you would want the MAC and IP to be the same in case you had to use the backup. For your case of cloning the VM to build a cluster you'll want to re-initialize the MAC on every clone.enter image description here

Update 1 In response to your comments from 10/8/2013.

Make sure the IP address is not statically set. You mentioned in your question that the VM should be getting it's IP from DHCP. If thats the case the config should look something like the following. For debian based systems it will be found at /etc/network/interfaces

auto eth0
iface eth0 inet dhcp

For redhat based systems the networking configuration is at /etc/sysconfig/network-scripts/ifcfg-eth0

Your second comment mentioned that eth0 is missing. Do you have an eth1? Since your computer changed mac addresses, the OS keeps the original mac as eth0 and usually assigns eth1 to the new mac. To reset the eth* devices so you have an eth0 and not an eth1 you'll need to clear the udev networking rules.

Messing with networking can get hairy. One option would be to delete your cloned VM and clone the original again and check "reinitialize mac". I'm not certain it will fix your problem but it might.

tbenz9

Posted 2013-10-07T20:47:43.607

Reputation: 5 868

3I did that and restarted both VMs but they were still assigned the same IP :( – amphibient – 2013-10-08T14:39:57.187

the clone does not have eth0 when i run ifconfig – amphibient – 2013-10-08T14:42:58.667

I updated my answer to address the issues you wrote about in the comments. – tbenz9 – 2013-10-09T18:09:51.590

@amphibient, I re-created your problem and was able to solve it easily by deleting everything out of the /etc/udev/rules.d/70-persistent-net.rules file and rebooting. Good luck! – tbenz9 – 2013-10-10T04:58:50.823

1

I got the same IP 10.0.2.15 VM's when I cloned Ubuntu on Mac.
To solve the issue I first shutdown the VM's.
Then for each VM
I select settings, then click Network tab, then changed attached to: Bridged Adapter
then I click advanced, select allow all for promiscuous mode,
finally refresh the MAC address to change the MAC address. Click Ok.
Now Start the VM's and you will get the different IP addresses.
I got 192.168.0.14 for first and 192.168.0.15 for second. They were pingable from host Mac too.

enter image description here

Mian Asbat Ahmad

Posted 2013-10-07T20:47:43.607

Reputation: 131

0

Please read about available adapters in VirtualBox (https://www.virtualbox.org/manual/ch06.html#networkingmodes). If you want connection just between VMs then for your tests will be more suitable Internal Network adapter. However from you comment I get that you are using NAT.

I checked below scenario on VirtualBox 5.0.2 on host Mint 17.2 and guests Fedora 21:

Create main VM with default NAT adapter. Create Linked clone (https://www.virtualbox.org/manual/ch01.html#clone) with MACs reinitialization. Cloned and original VM have same values in file:

/etc/sysconfig/network-scripts/ifcfg-enp0s3

however

ip a

shows different MAC addresses on each one.

When I updated HWADDR in that file according to link/ether value from ip command and changed UUID with new one using

uuidgen

then despite the same IP on these (enp0s3) interfaces on original and cloned VMs, external network (Internet) was working well.

edwardo

Posted 2013-10-07T20:47:43.607

Reputation: 1

0

I came across this same situation today. I was using a NAT adapter and a Host-only Ethernet Adapter for my Solaris VM. The IP of the clone changed when I refreshed the Host-Only adapter's mac address.

xbox

Posted 2013-10-07T20:47:43.607

Reputation: 1

-1

I understand your pain. I cloned my vm. Generated new Mac on oracle virtual box, Booted clone up, changed hostname and updated the network-scripts file with new mac.

When rebooted, it still used same ip from dhcp. Interface is on Nat setting.

:(

Dave

David Sives-Rutherford

Posted 2013-10-07T20:47:43.607

Reputation: 1

1Kind and friendly but not an answer to the question. – Alexx Roche – 2019-01-17T16:03:02.793