Search code examples
iphostianarfc1123

Valid host ip address


I am now maintaining a piece of code that has a warning not to use the value 0 or 255 in an IP address for hosts.

Can someone help and shed some light on the restriction, if any, on IP address for host? It is mandatory to backup the info from a trusted source.

I found a few sources around the internet but non are official or trusted enough.

The most reliable info I found until now is located at RFC1123 section 2.5 and here at the IANA IPv4 Address Space Registry.


Solution

  • Back in the days of Class A, B, and C addresses, a class C address that ended in .0 referred to the entire subnet, and .255 was the broadcast address for the subnet. So these addresses couldn't be used for individual hosts.

    However, address classes became obsolete decades ago, when Classless Inter-Domain Routing (CIDR) was developed to make more efficient use of IP addresses. This is described in RFC 4632. The general idea is that each network has an explicit subnet mask, which need not exactly match octet boundaries in IP addresses. So the assumption that .0 and .255 are the network and broadcast addresses is no longer valid.