Sunday, October 11, 2009

My Guest OS cannot ping My Host OS in Virtual Box

The default networking setup for VirtualBox is NAT, which means basically that your host computer is acting like a router, creating a virtual network for your virtual machine to connect to. Naturally, this network has it's own IP scheme.

I have a router(gateway) 192.168.1.1 (255.255.255.0)
host computer 192.168.1.5

I was trying to manually set up my guest to static ip 192.168.1.12 and found it cannot ping my gateway, neither can access internet.
By default the ip of guest is 10.0.2.15, it can access internet and my router(192.168.1.1)

To fix the issue, I had to use Bridge Network.
1) Virtual Box -> SETTINGS -> NETWORK -> Bridge -> Edit Setting -> Add your active adapter for internet/network (in my case I am using Wireless Adapter en1: AirPort of my MacBook )

2) Then I started my guest OS. Say I have Windows XP as my guest OS. I need to edit the network settings. Manually add the IP ADD, DEFAULT GATEWAY, DNS. Since my router act as DNS for my LAN, I used DNS same as my DEFAULT GATEWAY.