Why does resolve to the loopback device?

$ curl --verbose
* Rebuilt URL to:
* Hostname was NOT found in DNS cache
*   Trying
* Connected to ( port 80 (#0)

It follows from an RFC requirement. RFC 5735 says:

  1. Global and Other Specialized Address Blocks - Addresses in this block refer to source hosts on "this" network. Address may be used as a source address for this host on this network; other addresses within may be used to refer to specified hosts on this network

That given, the only rational thing to do with as a destination is to treat it likewise. You can't route it anywhere else, because return packets would violate the RFC; you can't say it's invalid, because it's not when used as a source; the only sane thing to do with it when used as a destination is map it to localhost as well.

One of my old colleagues used to use telnet 0 22 as a real timesaver for telnet localhost 22.

  • 1
    The quote above sounds like it's talking about using as a source address, as opposed to a destination address. – Daniel Jul 16 '15 at 6:41
  • It is; see my expanded comment above. – MadHatter Jul 16 '15 at 6:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.