Ubuntu VirtualBox with Static IP on Windows Host

Bridge Adapter

Go to the virtualbox settings and change the network type to be bridge adapter. Then boot the box.

Edit the interface

sudo nano /etc/network/interfaces

You will find a line saying something like iface eth0 inet dhcp. Replace this line with the following lines.

iface eth0 inet static

The new IP address of your virtual machine is on the second line. Choose an IP address high in the range (i.e. so it is unlikely other computer will be issued with the same IP. The gateway address should be the IP of your router.


What most other tutorials forget to mention is although this gives the virtual machine a static IP, the machine cannot resolve web addresses as it does not have a nameserver (ie it can get incoming connection but can get connection to the internet). So you also need to specify a nameserver in etc/resolvconf/resolv.conf.d/base

Add the following lines (Google Public Nameservers) or use the IP address of your router.


Reboot the server

sudo reboot

And everything should work, you can test it but typing

ping google.com

and to cancel