Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
setup a vbox ubuntu server with host only adapter

Virtualbox dev environment w/ static IP

I can never find a great guide on this stuff, so these are more like notes to myself.

The goal here is to have a virtualbox running more or less headless. An ssh client is used separately to actually use the machine. I've found it to be fantastic for a quick dev setup.

lets go

Assumes you have a vbox setup with Ubuntu server (this will work for 16.04) ready to go.

sudo apt-get install openssh-server

In the virtualbox settings:

image

Add a host only adapter to your machine. Virtualbox should come with one that is setup already.

You can find the settings for the Host Only adapters here:

image

What has worked for me is picking an IP in the range defined here.

For example 192.168.56.101

Ensure you reboot the virtualbox

ifconfig -a

Look for the new device name here, mine was enp0s8, it will be used in the following examples.

The interface is not configured yet and is not up on boot - lets do that.

sudo vim /etc/network/interfaces

A good step to just test out the host only device would be setting up the interface with DHCP. You can do that with these lines (but skip if you want to straight to staticip)

auto enp0s8
iface enp0s8 inet dhcp

If you then save file, reboot and run ifconfig again, you should see your device with an IP. Try to ssh to it!

Now on to static (remove or comment the dhcp entry if you added it). Edit /etc/network/interfaces top add:

auto enp0s8
iface enp0s8 inet static
address 192.168.56.101
netmask 255.255.255.0

Save and reboot, run ifconfig again, your interface should be up!

Now try to ssh to it.

Windows

ssh clients*

quickly to add this to your hosts file (open cmd as Administrator)

echo(>>%SystemRoot%\System32\drivers\etc\hosts&echo 192.168.56.101 devbox >> %SystemRoot%\System32\drivers\etc\hosts
@harishgouthamv

This comment has been minimized.

Copy link

@harishgouthamv harishgouthamv commented Apr 13, 2018

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.