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

This is for discussing general topics about how to use VirtualBox.
Post Reply
phpguru
Posts: 3
Joined: 13. Oct 2010, 18:11
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu 10.04

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

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

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

Post 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.
phpguru
Posts: 3
Joined: 13. Oct 2010, 18:11
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu 10.04

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

Post by phpguru »

I'm currently using bridged mode. Is it possible to force vm2 to get a different IP from the DHCP server?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

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

Post 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.
phpguru
Posts: 3
Joined: 13. Oct 2010, 18:11
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu 10.04

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

Post 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.
Post Reply