Windows – Can the name “localhost” in a virtual machine be mapped to IP of host machine

localhostvirtual-machinesvirtualhostwindowswindows-virtual-pc

I have a virtual machine image (using Virtual PC) of Windows XP/IE6 from Microsoft's "modern IE" website. This virtual machine is hosted by a Windows 7 machine.

I have a local web application on the host machine and need to check it in IE6 (sadly). Inside the virtual machine, can the "localhost" name be mapped to point to the IP of the host machine? I tried editing the c:/windows/system32/drivers/etc/hosts file in the virtual machine to [IP address of host machine] localhost but that doesn't work. The reason I want to use "localhost" rather than an IP is because some of the web application's configuration files point to "localhost."

I can change the configuration files to point to a different domain name, but I wanted to know if the "localhost" name itself can point to something else. I get the feeling that "localhost" is some type of reserved keyword that only points to 127.0.0.1.

Best Answer

No, you cannot do that.

RFC 2606, defining the "reserved TLDs" specifically prohibit it so pretty much all TCP/IP stack will always statically bind "localhost" to the local loopback address (127.0.0.1)

If you're using IIS as a web server, you can use application request routing to create a "proxy" rule that will then fe6tch that document from another host.

Related Topic