Is it always possible to ping localhost and it resolves to 127.0.0.1?
I know Windows Vista, XP, Ubuntu and Debian do it but does everyone do it?
Any correct implementation of TCP/IP will reserve the address 127.0.0.1 to refer to the local machine. However, the mapping of the name "localhost" to that address is generally dependent on the system hosts
file. If you were to remove the localhost entry from hosts
, then the localhost name may no longer resolve properly at all.
127.0.0.1 is reserved in any IP stack for the local host.
"localhost" as a host name is not guaranteed to be there. If the host/DNS settings are misconfigured, localhost will not resolve.
Example on a debian box:
topaz:/root# vi /etc/hosts
[comment out localhost entry]
topaz:/root# ping localhost
ping: unknown host localhost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With