0

Say, I have 2 guest machines. One is in network vboxnet1(IP: 192.168.59.1 mask: 255.255.255.0). Another is in network vboxnet2(IP: 192.168.60.1 mask: 255.255.255.0). Both machines could reach the host in each host-only network. It is possible to connect these 2 networks such that machines in vboxnet1 could reach machines in vboxnet2? You may have other ways to do this using other configuration alternatives.

0

EDIT after discussion in comments:

Connecting the two Host-Only Networks would require a router; a third VM can be connected to the two networks and configured as a router.

..

However, you don't need to connect the host-only networks. Guest machines can be connected with an Internal Network: https://www.virtualbox.org/manual/ch06.html#network_internal

Instructions:

1) DHCP server.

Setup a VirtualBox DHCP server using the following command:

vboxmanage dhcpserver add --netname intnet --ip 10.10.10.1 --netmask 255.255.255.0 --lowerip 10.10.10.2 --upperip 10.10.10.10 --enable

All IP address values can be changed as needed.

The --netname specified MUST be used in the configuration of the VMs' network adapters.

2) Set up an Internal Network Adapter per VM.

For each VM, you need to create a Network Adapter:

  1. In each machine's settings, go to Network,
  2. Enable a Network Adapter, and select "Attached to" : "Internal Network",
  3. Set the Name to the same as the netname given to the DHCP server.

3) Bootup Virtual Machines!

Once bootup up, use ifconfig command to check that a new adapter is available with an IP address in the range of lowerup and upperup specified in the DHCP server above.

That's it, the machines are now connected.

7
  • the question could be rephrased to: is there some ways to let one guest in network A reach another guest in network B in virtualbox? Your answer is based on DHCP. From your example, a guest could gain one IP ranging from 10.10.10.2 to 10.10.10.10, which is in the same network.
    – JACK M
    Jul 3 '16 at 17:36
  • Your question is a little unclear... I read this "other ways to do this using other configuration" and thought you just want any method to connect different machines.
    – jehad
    Jul 3 '16 at 17:54
  • To connect two different networks, one way is... Create a THIRD machine, connected to the two host-only networks. This third machine can then be configured as a router. But, why would you want to do this?
    – jehad
    Jul 3 '16 at 17:57
  • sorry. I just wonder whether there are some ways to do that without router
    – JACK M
    Jul 3 '16 at 18:05
  • To my knowledge, no. There is no other way. Someone else might know more than I do.
    – jehad
    Jul 3 '16 at 18:10

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.