vmware and localhost

Recently I’ve included into my suite of software VMWare Fusion. I was previously using the open source Virtual Box and a copy of Windows XP to emulate IE7 inside of my mac. I’m a web developer so IE counts wether I like it or not.

Even though I had these tools I realized to hitting into localhost was not as easy as just typing localhost:9000 or what ever port into my emulated IE. So I did a bit of research and found this post from Rowlandos Blog which I am simply going to paste here as a reference

Type ifconfig vmnet1 into a Terminal window. You should get a return like this:

vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> 
mtu 1500 inet 192.168.115.1 netmask 0xffffff00 broadcast 
192.168.115.255 ether 00:50:56:c0:00:01 

The “inet” number is your “secret” IP (in my case, 192.168.115.1).

Now that we have that number, we can edit the hosts file on the VM. We find it in: C:/WINDOWS/system32/drivers/etc. Just open the host file with Notepad, and add each virtual host (domain) on it’s own line at the end of the document, like so:

192.168.115.1 dev.triumphofgrace.com 

… and save. Afterwards refresh the VM’s DNS cache by typing ipconfig /flushdns in a command line window.

Boom, you can now point to your macs localhost from your emulator and test all that you need to test in Windows.

Best of luck!