Configure Virtualbox guest with static IP, SSH and internet access from host

Solution 1:

Having two virtual adapters, one set to NAT and the other to Host-only, is the correct way to proceed. You may have had firewall or other connectivity issues with the guest is my guess.

Could you provide a little more information? The Host-only adapter should work with DHCP by default - though static IP addresses are fine too as long as it matches the configuration in your VirtualBox preferences. The screenshot below shows how my Host-only network is configured - any valid address in the 192.168.56.1-99 range should be acceptable for static use.

VirtualBox Host-only network configuration

You can find the network configuration under File -> Preferences (Ctrl+G), then selecting the Network section and clicking the "screwdriver" button to view/alter the configuration for the selected network.

Solution 2:

What kind of network adapter did you give it Virtualbox. I would use Host only IF you are going static. And then just add it to your local network. BUT..

  • If you go with a static IP you may hit problems when changing networks tho because not all networks use the same private IP address scheme. Some may use 192.168.x.x, others may use 10.x.x or any other private addressses that are unroutable on the interweb. This means you will have to reconfigure your IP every time you go onto new network.
  • Secondly they may use different gateways. Again this means you wont be able to hit internet from VM.

I would strongly adivse not using static IP's if you are going to be changing networks all time. Just use a Dynamic and use NAT. This meansits can connect to the internet from VM and you will still be able to access it through SSH from host.