Networking – Setting up static IP for virtualbox


I was learning arpspoofing.I was using my Ubuntu machine as the Man in the middle, an Ubuntu in my virtualbox as the target and my default gateway(Which is as the target gateway. In order to sniff the traffic between two machines the machines must be in the same network. When I checked route -n on my virtualbox host it showed that it uses the gateway address which is different from the one I use for my host machine.

Is it possible to bring the virtualbox to my network and assign any static IP like 10.7.1.x?

Best Answer

In the VB guest configuration for the Ubuntu, change the network adapter 1 type from NAT to Bridged Adapter.

Then start Ubuntu guest and change as root (or sudo) the /etc/network/interfaces to setup a static interface:

auto eth0
iface eth0 inet static

And make sure to remove or comment out any stanza mentioning dhcp. Restart your network with sudo service networking restart or restart your guest.

If you need domain name resolution on the Ubuntu guest, you will also have to add a DNS in the /etc/resolv.conf. For example