Networking with VirtualBox

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! :'(


Hi Manoj,

I have been breaking my head over virtualbox for the past few days. I came to know about it at a party at a friends place through some sysadmin guy. Now when I had to setup an internal training for my India DBA team, I thought of trying virtualbox when networking was not working with vmware. Thats when I came across your blog. Seems like you have tried interesting things.

I needed Static IPs (one public, one private) for setting up 10g RAC. I could NEVER make static IPs work on virtualbox with NAT. But as soon as I set DHCP on SLES9 guest OS (host windows XP), networking worked like a charm!

So one problem solved. But another one yet to go.. that of host networking or internal networking.

Ideally speaking, for me, internal networking is what I need, since RAC nodes need a private network (interconnect) that they ONLY they can talk to. But so far, my attempts to make internal networking work have not borne fruit.

One weird observation seems to be that when I setup Internal Networking option for NIC2 in the guest OS settings, the adapter defaults to Virtualbox Adapter 1 automatically, even if I forcibly set it as Virtualbox Adapter 2 (after selecting networking type as Host Only as a workaround -- for other values of networking type, it wont let you select a value of Interface Name field!). You see this after you reopen the settings of the guest OS -- and there is is. Your previous setting is gone like the wind. Damn!

Another interesting bug seems to be that when I put the internal network name as "intnet" (although the manual says that the default internal network name will be intnet) -- guess I want to force its hand, eh -- the second machine hangs on being powered up.

So, Is there anyway to make internal networking work on windows host. I can see many useful posts on internet for making it work on ubuntu linux host, but thats where it seems to end.

Posted by gaurav on April 13, 2008 at 02:58 AM MDT #

Hey, I came across, which says it a spells out the internal networking's process a little more clearly. In this situation, the person is setting up 3 virtual machines to talk within themselves:

The intnet network type is not available from the GUI, and is reset by the GUI if any of the VM settings are changed. So this has to be performed from the command line....We choose to use a network name of 'testnet' just for convenience. It is an arbitrary name but must be consistent.

Another requirement seems to be that the internal static IP within the guest OS will need to use a default gateway == host IP address. For example, if the host had an IP of (say) by virtue of being behind a router, then the default gateway of eth0 in the guest OS should be

I will be trying this combination and will see what happens.

Posted by gaurav on April 13, 2008 at 03:28 AM MDT #

Manoj, it worked. I will be posting an article on with the example. I tried to connect to copies of Ubuntu Gutsy Gibbon using a private network and it worked. Now the pending item is to get an external IP for the NAT'ed network for each Ubuntu Gutsy Gibbon guest OS. If you have any ideas for this, please let me know.

Posted by gaurav on April 13, 2008 at 05:28 AM MDT #

Excellent article guys - Just what I was after.

Posted by guest on November 04, 2008 at 04:51 AM MST #

Hi, i need help!!

i recently installed virtuabox on my xp pro host laptop and just installed xp guest through virtualbox. I have installed guest additions but the internet does not work. Please help. I cant find out what to do. Everytime i open virtualbox, the internet on my host OS (xp sp2) becomes inaccesible and goes down to 1.0 mbps. the only way to get internet on my host OS is by restarting the computer.

I cant get internet on my virtual machines at all.

Posted by Sid on December 07, 2008 at 04:41 AM MST #

Thanks Manoj That was really a worthy info which I was looking for

Posted by Balaji Subramanian on April 22, 2009 at 09:01 AM MDT #

[Trackback] Until recently I’ve been using VMware Fusion for my testing needs. With the release of Snow Leopard, Fusion no longer cut it. It was buggy on SL, and lacked 64-bit capability. Since I’ve set my system to boot 64-bit by default Fusion did...

Posted by on November 07, 2009 at 08:32 AM MST #

Hello ,

I installed a Virtual Machine with Window XP on my Winmdow Vista Box What happens is that my computer uses WiFi to access the internet. I followed all the instructions using NAT yet I am not able to get online. I have an ie on the VitualBox. How can I set the Network up for a single Virtual Machine


God Bless

Posted by guest on April 01, 2010 at 07:46 AM MDT #


Posted by guest on September 13, 2010 at 10:12 AM MDT #

Post a Comment:
  • HTML Syntax: NOT allowed



« June 2016
My previous incarnation

No bookmarks in folder