Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wish to run VirtualBox with my Ubuntu laptop on the home network (so the desktop PC can access it through the router) and also be able to ssh into the VirtualBox from host on the go (different network or with no internet).

Previously, the only network adapter on the VB instance was a 'bridged connection' adapter. This allowed me to access the internet on the guest VB and for the other computers on the LAN + host to access it. However, whenever I took my laptop off the network, I could no longer access the guest from host.

I read that I needed to enable a host-only adapter to access it off the network and a NAT adapter is used to access the internet from guest.

My question is can I run a host-only adapter + a NAT adapter alongside a bridged network adapter in VirtualBox? I am confused what I would put inside /etc/hosts? Would I put both IP's (host-only and bridged) with the same servername in /etc/hosts?

share|improve this question
    
I am not sure what you mean by 'soft-bridge' –  ril44 Mar 16 '12 at 23:41
    
no problem. I tried running the host-only adapter alongside the bridge. I could ssh into with host on the bridged IP but I couldn't get in with the host-only IP. I get a error message "no route to host" –  ril44 Mar 17 '12 at 0:14
1  
Figured it out. I was following this tutorial: christophermaier.name/blog/2010/09/01/… And I was putting in eth1 instead of eth2. I had to use eth2 because host-only was 'adapter 3' in the VB settings-network (using VB's GUI). Now I am able to run both bridged and host-only! –  ril44 Mar 17 '12 at 0:47
1  
For /etc/hosts: On the host machine I put: 'host-only-IP' 'servername' On the guest VB I put both the host-only and the bridged IP's with the same servername. Doesn't seem to cause a issue. –  ril44 Mar 17 '12 at 0:56
    
Sorry, I can't find the trick I used to get dynamips to work while I wasn't connected to a network. It had something to do with arp/proxy-arp and tricking linux in to thinking a virtual device had a real device behind it. I'll star it in case I run across it. –  hbdgaf Mar 17 '12 at 1:38
show 1 more comment

1 Answer

up vote 7 down vote accepted

Figured it out. I was following this tutorial: http://christophermaier.name/blog/2010/09/01/host-only-networking-with-virtualbox And I was putting in eth1 instead of eth2. I had to use eth2 because host-only was 'adapter 3' in the VB settings-network (using VB's GUI). Now I am able to run both bridged and host-only! – ril44 Mar 17 at 0:47

For /etc/hosts: On the host machine I put: 'host-only-IP' 'servername' On the guest VB I put both the host-only and the bridged IP's with the same servername. Doesn't seem to cause a issue.

So to summarize; I have 3 adapters on the VB instance, 1)Bridged 2)Nat 3)Host-only. I have the host file on my host machine configured to use the host-only IP and my desktop host file is configured to use the bridged IP address. This way I can take out my laptop off the network and still be able to ssh into my VirtualBox server without changing any settings. Then I can turn the NAT network adapter on and the VirtualBox can use my hosts network for the internet away from my home network. Cheers!

share|improve this answer
    
useful link, thanks. –  pylover Mar 9 '13 at 17:09
add comment

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.