For windows host and linux guest, I typically set up the guest to have 2x network interfaces. In the vbox GUI, the 1st interface is set to NAT, and the 2nd is set to HOST ONLY.
This gives Ubuntu guest eth0 and eth1.
In /etc/network/interfaces, I add:
Code: Select all
auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0
Code: Select all
192.168.56.10 ubuntu
This also works great if you have a laptop and take it to starbucks and use their wifi. Your guest ubuntu uses the NAT interface to access the internet over their WiFi. You still use the host only network to communicate guest <-> host at starbucks. That is, no matter where you take your laptop (like the Oracle Cafeteria!), you can communicate host <-> guest, and both host and guest can access the internet.
ADDITIONAL STEP - NOT REQUIRED
Additionally, if you have two machines or more on your home/office lan and you want to access the guest Ubuntu from a different machine altogether, you add a 3rd interface (eth2) which is BRIDGED networking. On my home lan, my wifi router uses network addresses 192.168.1.x, so I configure eth2 in the guest:
Code: Select all
auto eth2
iface eth2 inet static
address 192.168.1.10
netmask 255.255.255.0
Code: Select all
192.168.1.10 ubuntu
A bit more about the .10 address. For HOST ONLY, I see my host OS has an interface set up by vbox installer with IP of 192.168.56.1. If you set up host only networking and use iface eth1 inet dhcp, then the guest will set up eth1 via DHCP but talking to the built in DHCP server in vbox! Thus it will get an IP from 192.168.56.100 or greater than .100. Thus any IP 192.168.56.2 through 192.168.56.99 are safe to use as static. Similarly, my router comes default configuration to do DHCP for all the host-type computers on my LAN for 192.168.1.100 or greater than .100. Thus the same .2 through .99 type range is safe to use for static IP. I mean, I chose .10 because it's in this safe range, you can choose any number that you want.
I think it's a good idea to arrange blocks of the available IP addresses for specific purposes. For example:
.10 through .19 for your physical machines (hosts).
.20 through .29 for your VMs
.2 through .9 for any network printers or other devices
etc.
If you set up eth0 and eth1 as I described earlier, you should be able to ping in both directions. From guest, try:
Code: Select all
ping 192.168.56.1
Code: Select all
ping 192.168.56.10
BRIDGED NETWORKING
I use bridged networking for my Ubuntu VMs on my office LAN. The VMs only have one network interface, eth0, and in the vbox GUI it is set up as BRIDGED.
In Ubuntu, my /etc/network/interfaces file looks like this:
Code: Select all
auto eth0
iface eth0 inet dhcp
The same strategies work no matter what host and guest OS you choose.