Networking with VirtualBox
By manoj on Mar 13, 2008
In my earlier post, I described how I setup Indiana on my laptop.
I had two must haves for my work - virtual machines, and support for my ethernet card. My Indiana Preview 2 installation met both; well sort of...
I installed VirtualBox and then went on to install OpenSolaris build 84 and CentOS 4.4 on virtual machines. While VirtualBox is a bit different from VMWare, the installation was a piece of cake.
Setting up NAT took care of Internet access for the VMs. The NAT interfaces use DHCP. Piece of cake again.
Then my troubles started.
I need to SSH in to my VMs. On VMWare it is as simple as adding host-only network cards to the virtual machines. The host is automatically on this network. The VMs can also talk to each other over this network.
On VirtualBox, things are a bit different. The host can talk to the guests (AFAIK) only by setting up port forwarding. This is explained in the VirtualBox User Manual.
The following commands did it for the 'osol' virtual machine. I could ssh and sftp in!
$ VBoxManage setextradata "osol" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP $ VBoxManage setextradata "osol" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22 $ VBoxManage setextradata "osol" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222 $ ssh -p 2222 root@localhost $ sftp -o port=2222 root@localhost
See also Renaud's post.
If you have multiple VMs, use different host ports (2222, 2223 etc).
One problem solved. However, the VMs still can't talk to each other. To do that I needed InternalNetwork. This is also explained in the UserManaual.
Setting it up is easy. Using CLI, this is what I did.
$ VBoxManage modifyvm osol -nic2 intnet $ VBoxManage modifyvm osol -intnet2 intnet $ VBoxManage modifyvm rhel -nic2 intnet $ VBoxManage modifyvm rhel -intnet2 intnet
That's it. In theory this should have just worked. However it did not.
I spent a couple of days fiddling around with this. I could ping the other node at times. But once I try to ssh in, ssh fails and ping fails thereafter!
To isolate the problem, I made a copy of the linux VM and InternalNetwork worked fine between the linux VMs. That suggested, I was not goofing up with the VirtualBox setup.
Next, I tried with two OpenSolaris VMs. The same problem showed up again - I could ping but ssh failed. After this failure, ping also failed.
This suggests a bug somewhere. But hey, VirtualBox is still beta on OpenSolairs. I am hopeful that this issue will get sorted out soon.
But till then, I am going back to Ubuntu. Bye bye OpenSolaris! :'(