3

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.

3 Answers 3

3

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.

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.

3
  • 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
    Commented Jun 8, 2012 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. Commented Jun 8, 2012 at 11:20
  • yes but what I mean is that assignation, you make it in the router interface right?
    – DevAntoine
    Commented Jun 8, 2012 at 11:22
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .