The goal:
I use Windows XP as a primary OS. I'm a Web developer and use a LAMP server for my development. Both OSes need to talk to each other, i.e. my Windows host needs to connect to the LAMP server for Samba, to access my source files, and an HTTP connection, to test on a browser. I also need to ssh the guest, but that is implicit in achieving the previous two.
Additionnally, the Ubuntu guest needs an Internet connection, primarily to commit my work to my main server and for the inevitable download when developing.
Normally this is easy to achieve using a router. But I lent it today for about two weeks and needed to change my configuration accordingly. As a side note, the network configuration is essentially the same for a router setup, except that the router's IP address is used as gateway instead of the shared connection LAN adapter.
The guest:
- Ubuntu 9.04 Server
- Static IP address (so I don't have to change my hosts file at every DHCP update)
- Windows XP
- Running VirtualBox 3.0.4
- Virtual machine's network configured using Host-only adapter
- Local Area Connection, Firewalled and Shared
The Ubuntu guest network configuration is:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.50 # Arbitrary static IP
netmask 255.255.255.0
gateway 192.168.0.1
At this point, the Windows host should be able to communicate with the Ubuntu guest, which should have a working Internet connection. Even without sharing the connection, the host should have been able to connect to the guest. But the guest would not be able to access the host and would not have Internet access.
There is a final piece of this, hardly necessary but which opened the way for the solution. Even with this configuration, the guest is not able to communicate with the host. This is not so much an issue since the guest is still able to connect to the outside world. But I was stuck at the fact that how can the guest access the Internet without being able to even ping the host? It turned out the problem lies in the Windows firewall, which blocked incoming connections from the VirtualBox Host-Only Network adapter.
The solution for this, if you ever need your Linux/Ubuntu guest to access your Windows host, is to disable the Windows firewall on the VirtualBox Host-Only Network adapter: Network Connections -> VirtualBox Host-Only Network -> Properties -> Advanced -> Windows Firewall -> Settings... -> Advanced -> Uncheck the "VirtualBox Host-Only Network adapter". Actually this can be done by going through the properties of any of the adapters. This way the Firewall remains active on the Internet connection, always a good idea when not using a router.
If anything is not clear and you're still stuck with this problem, please tell so as I would like this post to help the help the numerous people I have seen in forums trying to find a solution for this.