Is 0.0.0.0 a valid IP address?

后端 未结 10 1217
遇见更好的自我
遇见更好的自我 2020-11-29 04:14

Is 0.0.0.0 a valid IP address? I want my program to be able to store it as an indication that no address is in use, but this won\'t work if it\'s actually valid.

10条回答
  •  失恋的感觉
    2020-11-29 04:50

    It's valid inasmuch as it contains four octets, each within the range 0 through 255 inclusive. However, it's not usable as a real IP address.

    RFC1700 (a) states that 0.0.0.0/8 (0...) is reserved as a source address only. You can get into situation where it appears you have this address but that's normally because no address has been assigned to you (by DHCP, for example).

    See also Wikipedia entry on IPv4.


    (a) Although this RFC is now considered obsolete, it is still correct in terms of the given behaviour. Its replacement, https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml, still has the same text detailing use of the 0.0.0.0 address.

提交回复
热议问题