Virtual box host-only adapter configuration

networkingvirtualbox

I have VirtualBox 4 running on Win 7 with a Centos 6 guest VM set up for hosting my dev server. When I'm connected to my home network the guest can be accessed via a static IP address that I configured (192.168.56.2), but not when I'm in the office. I'm guessing that the DHCP server in the office doesn't have a gateway configured for the 192.168.56.x IP range. I read something about the VB host-only adapter that should allow me to set this guest VM up in such a way that I don't need to be on any network to be able to access the guest from the host using a static IP. I've not been able to find out exactly how to configure this though. Can anyone give me an example configuration, thanks.

UPDATE:

Thanks for your responses. I've now set up a single virtual network adapter in VirtualBox and set it to host-only:

C:\Users\Ben>vboxmanage list hostonlyifs
Name:            VirtualBox Host-Only Ethernet Adapter
GUID:            d419ef62-3c46-4525-ad2d-be506c90459a
Dhcp:            Disabled
IPAddress:       192.168.56.2
NetworkMask:     255.255.255.0
IPV6Address:     fe80:0000:0000:0000:78e3:b200:5af3:2a57
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 08:00:27:00:94:e8
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter

On the guest I've set up eth0 to use the same IP address as the host-only adapter (192.168.56.2) but when I try to log in using Putty I still get "Network Error : connection refused". VirtualBox DHCP servier is enabled but I can't ping the gateway (192.168.56.1) from either host nor guest. There's no firewall running on either OS. What next?

Best Answer

The manual explains how to do it. You have to create a host-only interface. It can be done with VBoxManage hostonlyif. You can check the current configuration with VBoxManage list hostonlyifs. This is a typical output:

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
Dhcp:            Disabled
IPAddress:       192.168.56.254
NetworkMask:     255.255.255.0
IPV6Address:     fe80:0000:0000:0000:0800:27ff:fe00:0000
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0

Name:            vboxnet1
GUID:            786f6276-656e-4174-8000-0a0027000001
Dhcp:            Disabled
IPAddress:       192.168.13.254
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:01
MediumType:      Ethernet
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet1