5

I have setup multiple guest hosts with NAT networking. On each hosts i have some portforwards so i can connect from my host (like 2222 to 22 host 1, 2223 to 22 host 2, ...).

How can i setup a guest-guest network connection with virtualbox?

3 Answers 3

11

I would suggest just adding a second network adapter to each of your virtual machines that is configured with the "Host-Only" option. You could also use a bridged interface but that can do weird things if you have a wireless network adapter. The Host-only option allows your VMs to communicate with your host, as well as each other. This also means you can get rid of the port forwards on your NAT configuration as your host will be able to directly talk to each guest. There is a DHCP configured on the Host-only network by default, and it will typically hand out addresses in the 192.168.56.101-254 range - so you can use the .1-100 addresses for static assignments as well.

  • Open your VM settings
  • Choose the Network secton of the settings dialog
  • On the Adapter 2 tab
    • Check the box for Enable Network Adapter
    • Changed Attached to to Host-only Adapter

VirtualBox VM Settings - Network

3
  • This sounds good. I am able to choose "Host-only Adapter" but there is nothing in "Name" field. The error message is something like "you did not choose a host-only network adapter". Mar 30, 2012 at 16:41
  • If for some reason you don't have a Host-Only network configured, you can go to the preferences for VirtualBox itself, on the network section and add a Host-Only Ethernet adapter.
    – Goyuix
    Mar 30, 2012 at 16:50
  • If I understand correctly, 192.168.56.1 is the address of the Host and 192.168.56.100 is the DHCP server on the Host-only network so I wouldn't use either or those as static addresses.
    – pgraham
    Apr 24, 2014 at 0:54
1

On linux guests simply modify /etc/network/interfaces and add a static up address, netmask and gateway.

e.g.

auto eth1
iface eth1 inet static
    address 192.168.56.101
    netmask 255.255.255.0
    gateway 192.168.56.1

The address range, gateway and netmask can be found from virtualbox -> preferences -> network just like Goyuix mentioned above.

Side note: I cloned one base VM to create a network of VMs. This also required changes to /etc/hostname and /etc/hosts files to give each VM guest a unique hostname. Also, adding a static entry in /etc/hosts for each networked VM helps DNS addressing (i.e. address by name instead of ip address).

0

if you mean Guest - Guest as in running 2 virtual machines on the same host and have them communicate then you could use Bridged adapters and set them all in the same subnet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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