Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running Linux (Debian Etch) in a VirtualBox VM on my MacBook. I usually ssh from my Mac terminal to the guest machine. I also want to access the internet from my guest, so I set up my host's WLAN card (en1) as a bridged adapter for eth0 on the client.

This works fine, but when I turn off the WLAN card (e.g. to reduce battery consumption), I'd still like to ssh from my host to the guest. This fails of course, because en1 loses its IP address.

Is a bridged adapter the best option for what I want to do? How can I make it work? (A simple "ifconfig en1 add 10.0.0.4" didn't do the trick...)

Thanks Chris

Edit:

I can currently live with the proposed workaround (secondary interface). Ideally however, I'd prefer a solution where I always access my guest system under a single IP from my LAN. If somebody knows an easy way to set up a virtual interface (as a bridged adapter) in my MacOS 10.6 host, and to make that route to the WLAN interface, I'd be happy to hear that. Other solutions are welcome, too!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

An easy workaround for this would to be to add a second host-only interface to the guest VM and to use that to connect from the host - that or use NAT networking from the host. I'm pretty sure that a bridged nic is necessarily going to reflect the state of the physical adapter.

share|improve this answer
    
Thanks, the second interface solution kind of works. But since the second adapter gets a different IP address, I can't continue my existing ssh sessions. I have tried the NAT network before, but while that lets my guest connect to the internet, I haven't been able to use that to communicate between host and guest so far. Is that possible somehow? –  Chris Lercher Mar 12 '10 at 15:25
    
I don't know how to connect over the network to the guest when using (only) NAT - my VM guest comes up with a 10.X.X.X interface which doesn't correspond to any of the interfaces on my vitualbox host (windows in my case). Regarding continuing sessions over a different interface, this is something you would have to handle through something like "screen" anyway, if I understand you. –  quadruplebucky Mar 12 '10 at 17:45
    
Hmm, ideally, I'd just have one interface. Maybe I shouldn't bridge to my WLAN card then, but to a virtual interface on my host instead. That virtual interface would then have to route to the WLAN. I get the feeling, that this will be some serious effort to set up. Or does anybody know an easy solution? –  Chris Lercher Mar 12 '10 at 18:01
    
I don't understand what your objection to two interfaces is - internet connection sharing via OS X sharing seems like it should work but the vboxnet0 interface does not appear in the interface options (not for me, anyway) –  quadruplebucky Mar 12 '10 at 18:27
    
Very nice idea! That would be very easy indeed, if it showed up there. –  Chris Lercher Mar 12 '10 at 19:01

I think the only way to guarantee that your VM will be reachable from your host no matter what interfaces are up/down/connected would be to define a host-only network for your VM and host and add an interface on that to the VM. Then you would always interact with the VM through that host-only network.

share|improve this answer
    
I think, this solution is a good workaround - the only problem that this causes is, that I will have to use a different IP when I want to connect from somewhere else on my LAN. Maybe I'll make a DNS entry for my LAN, and an /etc/hosts entry on the MacBook. - Still, I'd prefer a solution with just one IP for my guest machine... –  Chris Lercher Mar 12 '10 at 15:57

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.