[arin-tech-discuss] zero-padded IP addresses in "startAddress" and "endAddress" values

Andy Newton andy at arin.net
Thu Mar 29 09:56:57 EDT 2012


On Mar 28, 2012, at 10:17 PM, Seth Mattinen wrote:

> On 3/28/12 12:40 PM, David Huberman wrote:
>> Hello Dani,
>> 
>> ARIN's Registration RESTful web service has always expressed IP addresses
>> with zero padding. As you point out, however, the Whois RESTful web
>> service does not.  I think a fair explanation of these two behaviors is
>> that Whois is assumed to be read mostly by humans, and in contrast, the
>> output of the Registration RESTful web service is assumed to be
>> interpreted by machines.
>> 
> 
> I find that logic flawed; leading zeros can mean "octal" to machines. If
> indeed the output is assumed to be interpreted be machines as octal then
> leading zeros would be appropriate, whereas a human would normally read
> a zero-padded number as base 10. If you're going to zero-pad then for
> consistency you should return "075.0126.000.000" rather than an
> ambiguous mix of potentially octal and potentially base 10. Or simply
> don't zero pad without a technical basis.
> 
> For example, if I were to take that output and feed it into "ping" on
> any of my Linux servers they do indeed interpret 075 as octal and try to
> ping "61.126.0.0".

Seth,

Let me offer the technical basis you are asking for.

Zero padding IP addresses is useful for comparing IP addresses to each other as strings. Many languages and most databases do not have IP address data types, so zero padding enables easy comparison via string methods found in all languages and databases. This is particularly useful for determining if an IP address is greater than a starting address and less than an ending address, which is an easy approach for using a database to store IP address ranges and determining if a given IP address falls within that range.

That is what David is meaning when he says the data from Reg-RWS is to be interpreted by machines.

Is this helpful information?

Andy Newton,
Chief Engineer, ARIN




More information about the arin-tech-discuss mailing list