Is localhost host resolved to 127.0.0.1? [duplicate]

Possible Duplicate:
Why is “127.0.0.1 localhost” needed in HOSTS file ?

Is localhost host resolved to 127.0.0.1?

If "yes", then why does everything (IIS , ASP.NET, MS SQL Server, webapps, sharepoint, etc.) work on my WIndows XP Pro SP3 exactly the same if I use 127.0.0.222 (or any loopback IP 127.0..0.*) instead of 127.0.0.1?

Is localhost well-known Windows identifier?


The Loopback device (aka Locahost) is mapped to the whole range of 127.0.0.0 to 127.255.255.255, which is why it 127.0.0.222 works:

The most commonly used IP address on the loopback device is 127.0.0.1 for IPv4, although any address in the range 127.0.0.0 to 127.255.255.255 is mapped to it.

Update

See this article on host name resolution (specific to 2003, but should apply to XP).

Possibilities:

  • Your DNS server is responding with localhost for any 127.* query (unlikely)
  • The entry is still cached (ipconfig /flushdns to clear it out)
  • You may have an lmhosts file that maps it

I have seen that the default networks file in windows contain loopback 127, which may be why this works.

It is also quite possible that the mapping loopback / localhost is built into the TCP/IP stack itself.