Wednesday, June 10, 2009

Connecting from virtualbox guest to host

Seems simple enough, but I'm not sure why it took me so long to figure it out. I thought it would be a complex thing.

While making a website, using paste or just some small script, I can start up a test web server, and access the website I'm working on by going to localhost on port 8000..

http://localhost:8000/

I also wanted to connect to this using my virtualbox guest images (three of them, each having a different version of Interent Explorer), but obviously on those computers, localhost is local to Windows XP, and the test server is on the Linux box. Up until now, I just worked around this issue by putting them on another computer on my home network. But obviously this didn't work if I was away from home...

Virtualbox uses natting by default, so my Linux host was sort of working like a router. Thus, the answer was to do the same thing if you wanted to connect to a router: use the gateway address.

So, in my case, the gateway address for the Windows guest network interface was 10.0.2.2, so I could connect to the local computer using...

http://10.0.2.2:8000/

No comments:

Post a Comment