Page 1 of 1

How to get a 3rd IP address to 2nd VM

Posted: 19. Nov 2010, 21:43
by phpguru
I'm trying to set up a local development environment with multiple CentOS VMs running on the same Mac OS X host. I don't believe this question is specific to Mac OS X though.

I created a CentOS 5.5 VirtualBox VM - call it vm1 - and exported it to vm1.odf file. I imported this and set it up as vm2.odf. I can start both in bridged network mode... but when I do

Code: Select all

sudo /sbin/ifconfig
they are both reporting the same IP address. For my test sandbox to emulate the real word, I need VM's 2...N to each get their own IP from DHCP. Is this possible? If so, where do I change that for vm2 ?

Thanks in advance for any assistance.

Re: How to get a 3rd IP address to 2nd VM

Posted: 19. Nov 2010, 22:50
by Perryg
If you are using NAT this is exactly what you will have. Switch to Bridged if there is a router in the network or use host-only if there is not router.

Re: How to get a 3rd IP address to 2nd VM

Posted: 19. Nov 2010, 22:58
by phpguru
I'm currently using bridged mode. Is it possible to force vm2 to get a different IP from the DHCP server?

Re: How to get a 3rd IP address to 2nd VM

Posted: 19. Nov 2010, 23:09
by Perryg
If you are really using Bridged, then you are getting the DHCP address lease from your own router. I don't know why you would get the same address that way as it would make both guests unable to use the network.

Re: How to get a 3rd IP address to 2nd VM

Posted: 19. Nov 2010, 23:10
by phpguru
I just figured it out - or at least an easy way to do it. After I thought about what I wanted, this makes perfect sense.
I powered down vm2 and went into the settings for it in the VirtualBox manager.
Under Networking, turn off Adapter 1, and turn on Adapter 2.
Recycle the Mac Address a few times.
Save & restart the vm. Booyah.
VirtualBox is awesome.