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 an Ubuntu Server 12 virtualbox guest running on a Windows 7 host which has a dynamic IP (and I don't wanna change this considering it's a laptop and I'm changing network frenquently).

I want to have a static IP for my VM and a SSH access from my host but I still want to have the internet access on my VM.

I tried added a second host only adapter and configured /etc/network/interface to set eth1 to a static ip, but I can't connect via SSH to it.

Setting only adapter1 to host only works for SSH and static IP but I lose the internet access.

share|improve this question
add comment

3 Answers

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. Hope this has helped.

Bill

share|improve this answer
    
My first try was adapter1 set to NAT and adapter2 to host only. To have a dynamic IP via NAT I need to configure the router to forward the mac address but if I change the network I won't have that rule available. Ir is there a way in Windows to tell to assign a static IP to a mac address? –  DevAntoine Jun 8 '12 at 11:07
    
Sorry mate but that doesn't make much sense. Assigning a static IP does that. Your MAC address is just the hardware address for you NIC. Thats what assigning a static IP does. Essentially it gives your MAC a static IP. –  William Fleming Jun 8 '12 at 11:20
    
yes but what I mean is that assignation, you make it in the router interface right? –  DevAntoine Jun 8 '12 at 11:22
add comment

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.

share|improve this answer
add comment

Use bridged mode, in the network settings of the vm, and setup the ip addresses as you normally would Linux. Also install ssh and configure it the way you normally would.

share|improve this answer
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.