Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two virtual machines in VirtualBox. I would like to do networking between them. For the moment I have the default configuration on both, but they seem to have the same IP-address 10.0.2.15. I would also like to be able to use Internet with both, and that is Possible now.

By default the network-setting is NAT, but it seems like they cannot network internally since they have the same IP. But If I change to internal networking I guess that I cannot access Internet with the virtual machines.

How can I set up networking between virtual guest AND have access to Internet on them?

share|improve this question

9 Answers 9

up vote 17 down vote accepted
+50

Have you tried this Virtual Networking Guide ?

The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into VirtualBox. The IP address thus assigned to the virtual machine is usually on a completely different network than the host. As more than one card of a virtual machine can be set up to use NAT, the first card is connected to the private network 10.0.2.0, the second card to the network 10.0.3.0 and so on.

I think what you're looking for is "Internal Networking" , connecting internal VMs each other.

You can use a VM's "Settings" dialog in the VirtualBox graphical user interface. In the "Networking" category of the settings dialog, select "Internal Networking" from the drop-down list of networking modes. Now select the name of an existing internal network from the drop-down below or enter a new name into the entry field.

share|improve this answer
    
Thanks, that's right. Internal Networking is working but doesn't come with DHCP so I tried the Bridged solution and that works fine. Thanks. –  Jonas Mar 14 '10 at 11:01
2  
1  
@Joe Internet your link is OK, but I only understood it after reading blog.techprognosis.com/2011/02/28/…;. That said, I got the internal network running. I was not able to select host-only or bridged mode because suitable adapters are missing. –  bernd_k Sep 24 '11 at 17:19

I found the following solution for my environment:

  • first adapter with internal network to access the other VM-
  • second adapter with NAT to access the internet.

Those settings can be done by the GUI Oracle VM VirtualBox Manager. Initially I had the same problem as Jonas, I missed DHCP. Finally I found this article and I used:

VBoxManage dhcpserver add --netname intnet --ip 10.13.13.100 --netmask 255.255.255.0 --lowerip 10.13.13.101 --upperip 10.13.13.254 --enable

from the command line. Afterwards it worked fine.

I dare say that the manual is a poor resource, as most of the configuration of VirtualBox on a Windows host can be done by the GUI and it is a severe inconvenience that one can't configure DHCP with the GUI.

My environment: I'm running portable VirtualBox 4.1.2r73507 on Windows 7 64 bit. Currently host-only and bridged mode not working, because host-only adapter is missing. I have a problem similar to that described in a german question on Virtual Box forum, I have no host only adapter.

share|improve this answer

You need the host-connection LAN type (something like that in english version) on guest machines and bridge-connection on your host-machine.

share|improve this answer

This is how I connect vbox guests in NAT mode only (tested on VirtualBox 4.2.4).

Just use the gateway IP to go from one guest to the host. Then use port forwarding to "proxy" the host traffic into the other guest.

For instance if guest A wants to reach a guest B service that listen on port 1000, A has to use the gateway IP (for the first NAT interface it is 10.0.2.2). Then you need to configure port forwarding on guest B so that all traffic received by the host on port 1000 go to guest B on port 1000.

This might not work for every service but it seems to work just fine for ssh, salt, ...

In conclusion, you don't necessary need host-only mode to connect multiple guests but I don't mean to say that host-only mode is not the best option for your use case.

share|improve this answer
    
This worked flawlessly for my use case (testing ie8 on an xp guest connecting to a server in a linux guest). –  Ted Mar 7 at 16:01

(answer to question by bernd_k)

For sharing files between the host and guests, one actually shares directories rather than files.

If the network mode is bridged or NAT, then the host and guests are each equal network partners. Although the whole setup is contained in the one host, network-wise they are all equal on the network, as if they were physical machines. (NAT is sometimes more problematic to use than bridged.)

This way, any shared folder in any computer, virtual or physical, is available to all. Because not all virtual machines may be turned on all the time, it makes sense to setup one folder of the host as the shared folder. The host then shares the folder, and the virtual machines use it as-is or as a mapped drive.

The following article explains with great detail how to share folders in Windows :
How do I share folders in Windows 7 with the Shared Folder Wizard?

share|improve this answer
1  
Your hints are valuable at a later stage, but before sharing files or folders you must be able to ping the other machine. –  bernd_k Sep 25 '11 at 16:01

I have two network cards on my Oracle VM XP PC

1st Bridged with a fast IP address as im using this as a client with a server network configuration. Changed the default gateway to the same as network card two (Nat 2nd)

2nd Nat With obtain IP address from Oracle VM

works fine!

share|improve this answer

I don't know if it will work, but my idea is:

  1. Change IP to diff number in only one virtual machine (in NAT mode).

  2. Change other virtual machine to Bridged.

  3. Set settings on both systems to machines find each other. Restart everything.

If 1+3 or 1+2+3 don't work, try this: Make a Shared Folder on host machine and share the folder to the 2 virtualbox machines on virtualbox settings. Restart and voilá?

I know the second option is a workaround.

share|improve this answer

I did the following steps and it worked fine with me finally (on CentOS VB):

  • Use the NAT for the Primary Network adapter (Settings -> Network -> Adapter1 "attached to NAT").
  • Add another adapter (Settings -> Network -> enable Adapter2 "attached to Host-only Adapter") -> set "Promiscuous Mode" to "Allow All".
  • Start the VB.
  • Add another network interface (cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1).
  • Change the MAC address for eth1 according to the one which appears in the Adapter2 ((Settings -> Network ->).
  • Restart the network "service network restart"

Then this VB should access the Internet and could be accessible from the others (VBs and local machine).

Note:

The NAT adapter will be used to access the Internet while the Host-Only adapter will be used for networking access between any other VBs and the local machine as well.

share|improve this answer

Change the network attached to Bridged Adapter in the Network under Setting.

That's it; It can connect two virtual PCs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.