Page 1 of 1

Possible to HIF host and two guests without bridging?

Posted: 26. May 2008, 06:15
by quinthar
Is it possible to set up two separate guest VMs on the same network as the host without using bridging?

My goal is to have two Ubuntu 8.04 VMs share a virtual network with the Ubuntu 8.04 host. The VMs don't need access to the internet, they just need access to the host and each other. (Similarly, the host needs access to both VMs: I'm using Firefox on the host to test two load-balanced webservers, one in each VM.)

Ideally I could use the "internal" network, as the guests don't need access to the internet. This would let them talk to each other just fine. However, they need access to the host (and the host need access to them), so that won't work.

Next I'm thinking I could just bridge both VMs to the LAN and thus have all three nodes talk over the LAN. But I only have one IP on the LAN (I'm using a Sprint EVDO card), and I also need it to work without a real network connection (I do a lot of work offline).

Next, I've read you can use HIF to establish a connection between the host and the guest. But you need a separate virtual interface for each guest, and (so far as I can determine) guests can't see other guests' virtual interfaces.

The best option I can come up with is to use HIF to set up a connection between the host and each guest, and then the "internal" network to let the two VMs talk. But this doesn't match my live deployment well (each node in the real cluster is in a different datacenter, so ideally the IP the host uses to talk to each guest is the same as the IP the guests use to talk to each other).

So, I'm a bit stuck. It seems there must be some way to get two VMs to share the same HIF interface and thus neatly put both guests and the host all on the same network (and seeing the same IP addresses) without bridging both VMs to the LAN. But I can't figure that out. Any suggestions?

Thanks!

-david

Posted: 26. May 2008, 15:44
by Sasquatch
Type the following commands (if you use the binary version, else it might use different commands for creating virtual interfaces) and it should all work.

Code: Select all

sudo VBoxAddIF vbox0 quinthar br0
sudo VBoxAddIF vbox1 quintar br0
sudo apt-get install bridge-utils
sudo brctl addbr br0
sudo ifconfig br0 172.16.0.3 netmask 255.255.0.0 up
Now start the VM's with the Host Interface set to each of them (one with vbox0, other with vbox1). In the Guests, set the IP addresses to 172.16.0.1 and 172.16.0.2, or however you have it set up for loadbalancing. If this all work, put the settings in your /etc/network/interfaces file.

Using a bridge does not always mean you have to use your physical interface. Like for your example, you only need one interface for each VM and the Host can communicate with both VMs in the same subnet.