Running static ip Virtualbox images in ubuntu server in datacentre

Virtual machines have several advantages over physical servers. Especially restoring state and making backups. If you have minimal ubuntu server then first you need to install virtualbox. Best version at the time is virtualbox 4.

Add into /etc/apt/sources.list


deb maverick contrib

Now you can install virtualbox itself

apt-get install virtualbox-4.0

Easiest way to get VM running in server is to prepare image at home and upload this to server. Make sure you configure ssh and networking correctly (network configuration is explained bit later in here), network interface must be bridged to eth0
Once image is uploaded to server import this with command.

VBoxManage import vmname.ova

Run VM with command which make it run in background and dows not stop if you log out from ssh

nohup VBoxHeadless -startvm vmname &

If there was no problems then you are ready to go, almost.

You want to assign each VM static ip. In hosting providers, like Hetzner, network devices accept traffic only from MAC addresses of physical NIC-s and as VM-s have different MAC-s then by default they cannot communicate with outside world.

To solve this you need to set up routing in host machine, write into host machine

nano /etc/sysctl.conf



Now reboot host.

Configure guest machine, edit


and write there something like

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

where is extra ip assigned to you and is host machine ip.This tutorial helped to set up the networking

Leave a Reply

Your email address will not be published.