Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a mac host, and a VirtualBox Linux guest, currently using Bridged mode.

I need to be able to easily SSH into the guest from the host. It would be nice to use a hostname, but a never-changing IP address would be fine too (currently, the IP changes with each new network I join, and the hostname has never worked).

I also need internet access from the guest.

Other machines on the network do not need access to the guest.

What is the best way to configure my VirtualBox network?

share|improve this question
    
Related to this, consider starting the VB guest without GUI: superuser.com/questions/135498/… –  Fabricio PH May 23 at 20:21

3 Answers 3

up vote 21 down vote accepted

VirtualBox > Settings > Network > 'Host-only Networks' > Add (you will get vboxnet0)

ifconfig #will show you new interface vboxnet0

Shutdown your VM and do:

VM's Settings > System > check "Enable I/O APIC."
VM's Settings > Network > Adapter 2 > host-only vboxnet0

Start VM, on guest run

ifconfig

and check ip

Check these links:

  1. https://forums.virtualbox.org/viewtopic.php?f=8&t=40076
  2. http://www.wiredrevolution.com/virtualbox/setup-ssh-access-between-virtualbox-host-and-guest-vms

There is also solution for NAT but I haven't checked it.

Configuring port forwarding with NAT in your host machine

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

connect to your linux via the port 2222 of your host machine

ssh -l -p 2222 localhost
share|improve this answer
1  
Thanks, I ended up enabling the VirtualBox port forwarding and am able to connect via ssh localhost -p 7022. –  Thomas Hunter May 13 '12 at 22:39
    
Nice, the port forwarding worked like charm. Although I did the config in the Virtualbox GUI rather than with VBoxManage. There you need to set your host and guest IP adress as well, which should be 127.0.0.1 and 10.0.2.15 respectively. –  Sebastian Ganslandt Nov 26 '12 at 19:09
    
Minor edit to the first sentence. It should read: VirtualBox > Settings > Network > 'Host-only Networks' > Add (you will get vboxnet0) –  Steve Swinsburg Jul 8 at 6:47

Between two Linux machines (a 32-bit Ubuntu host and a 64-bit Ubuntu VM), I managed to get ssh working using this Port Forwarding:

enter image description here

share|improve this answer
    
I did exactly the same, just without entering any "Host IP" and "Guest IP". –  Damien Cassou Apr 14 '13 at 10:14
    
This worked for my NAT guest also. Thanks. –  Trastle May 15 '13 at 14:15

You might be better off configuring your virtual NIC in NAT mode if you are moving around quite a bit. Using NAT, the host (your PC) becomes the DHCP server and router for a private network which is created for your guest OSes. I'm pretty sure you can set a static address using NAT also...

However, I think the best solution is to suss out why name resolution isn't working for your guest VM :)

https://www.virtualbox.org/manual/ch06.html#network_nat

share|improve this answer
1  
I setup NAT mode, and my guest is assigned the ip 10.0.2.15. However, from the host (whose IP is 192.168.1.120), I am not able to reach the guest. The guide was able to explain the different modes for me, but it didn't seem to have a solution for my problem. –  Thomas Hunter May 13 '12 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.