How does one configure an Ubuntu guest to use a static IP that's visible to an OS X host, and ensure that the static IP is independent of the host's network configuration? I previously used bridged networking for my guest, but I'm constantly moving my host between networks so the guest IP is always different.

First, I tried setting the guest network configuration to NAT and forwarding host port 1022 to guest port 22, so I could at least ssh to a fixed address (localhost:1022):

$ VBoxManage setextradata "Ubuntu Server" "VBoxInternal/Devices/e1000/0/LUN#0/Config/SSH/Protocol" "TCP"
$ VBoxManage setextradata "Ubuntu Server" "VBoxInternal/Devices/e1000/0/LUN#0/Config/SSH/GuestPort" 22
$ VBoxManage setextradata "Ubuntu Server" "VBoxInternal/Devices/e1000/0/LUN#0/Config/SSH/HostPort" 1022

Then,

$ ssh localhost -p 1022
ssh: connect to host localhost port 1022: Connection refused

But this didn't work (guest has no network access with NAT and OS X refused the connection, as you can see).

I'd love a general solution that would let me communicate with my guest at a fixed IP.

link|improve this question
feedback

1 Answer

For starters, localhost points at 127.0.0.1. That VM may be running on your machine, but it is addressed separately from it.

When you turn on a NAT bridge in VirtualBox, it creates a separate, virtual interface to act as the “router” for the NAT clients you put behind it. You can’t connect to localhost to get to the VM because localhost is your Mac, NOT the VM.

Set up the guest as NAT, then check the address of the VM from inside it. use that address (its most likely a private address, 192.168.something) and try to connect from your host.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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