Why does 0.0.0.0 resolve to the loopback device?

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

It follows from an RFC requirement. RFC 5735 says:

  1. Global and Other Specialized Address Blocks

    0.0.0.0/8 - Addresses in this block refer to source hosts on "this" network. Address 0.0.0.0/32 may be used as a source address for this host on this network; other addresses within 0.0.0.0/8 may be used to refer to specified hosts on this network

That given, the only rational thing to do with 0.0.0.0 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 0.0.0.0 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.