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?
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 withVBoxManage list hostonlyifs
. This is a typical output:You can add a second (or replace the existing) NIC to the guest with a "Host-Only" as the networking type. The "Host-Only" NIC will also contain a DHCP server for the guest.
You can then access the guest VM from the host via the assigned IP address (you check the assigned IP for the guest via "ifconfig").