non operational question related to IP

i was pinging a host from a windows machine and made a typo which seemed harmless. the end result was it interpreted my input differently than what I had intended. thinking this was a m$ issue I quickly took the opportunity to poke fun at windows as the senior m$ admin was near by.

"look at how brain dead this os is, it can't even do simple math!"

He is now looking at my screen scratching his head…..

"watch, i'll open a shell on os x and show you how it can add 0 +10"

I open a shell on os x, same behavior as windows.

" ok so apple is brain dead too, watch, it'll work on linux!"

same deal…

long story short, it does work as expected on all our hardware routing gear. still not sure what is happening here…

osx-gwhynott:~ gwhynott$ ping
PING ( 56 data bytes

gwhynott@ops:~$ ping
PING ( 56(84) bytes of data.

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:

anyone happen to know how the OS's are interpreting the 010? doesn't appear work out in base[2-10] (1010,101,22,20,14,13,12,11,10,A)



Prefixing the octet with 0 makes it interpret it as octal, not decimal.

Pretty typical on a UNIX system.

'Octal' (Base-8) :slight_smile:

The leading '0' is telling the box to interpret it as octal instead of
decimal or hex.

Ken Matlock
Network Analyst
Exempla Healthcare
(303) 467-4671

Looks base 8 to me.


010 is how C represents an octal number. This one is known in decimal as 8.

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.

    --Steve Bellovin,

thanks guys. I should of paid more attention in school.

interesting cisco understands what we meant. 8)


Obviously, what Greg meant to type was:
$ ping 012.0xA.10.1
PING 012.0xA.10.1 ( 56(84) bytes of data.


He was on Windows, so he might have intended:

C:\>ping 168430081
Pinging with 32 bytes of data:


0 as a leading digit on an integer indicate octal...

010 octal is 8 decimal.


'Octal' (Base-8) :slight_smile:

The leading '0' is telling the box to interpret it as octal instead of
decimal or hex.

My guess you're seeing an interface that uses inet_addr() instead
of inet_pton(); the latter is used more nowadays at it supports
both IPv4 and IPv6 addressing schemes.

Whereas I've seen this behavior with a lot of vendors, I'm tempted
to call it a bug:

  The Open Group Base Specifications Issue 6
  IEEE Std 1003.1, 2004 Edition


  If the af argument of inet_pton() is AF_INET, the src string shall be in
  the standard IPv4 dotted-decimal form:


  where "ddd" is a one to three digit decimal number between 0 and 255 (see

No mention of dotted quad being anything other than 'decimal', much
less getting cute about guessing the radix.

The *BSD manpages for inet_pton() call out a similar constraint:

     The inet_ntop() and inet_pton() functions conform to X/Open
     Networking Services Issue 5.2 (``XNS5.2''). Note that inet_pton()
     does not accept 1-, 2-, or 3-part dotted addresses; all four
     parts must be specified and are interpreted only as decimal
     values. This is a narrower input set than that accepted by

As does Linux():

      src points to a character string containing an IPv4 network
      address in dotted-decimal format, "ddd.ddd.ddd.ddd", ...

RFC 2553 also calls out the non-decimal interpretation as being

  If the af argument is AF_INET, the function accepts a string in
  the standard IPv4 dotted-decimal form:


   where ddd is a one to three digit decimal number between 0 and 255.
   Note that many implementations of the existing inet_addr() and
   inet_aton() functions accept nonstandard input: octal numbers,
   hexadecimal numbers, and fewer than four numbers. inet_pton() does
   not accept these formats.


I've never been happy with inconsistencies in serializing data structures...

See man inet.

     All numbers supplied as ``parts'' in a `.' notation may be decimal,
     octal, or hexadecimal, as specified in the C language (i.e., a leading 0x
     or 0X implies hexadecimal; otherwise, a leading 0 implies octal; other-
     wise, the number is interpreted as decimal).

Note: inet_pton is supposed to only take dotted decimal quad (no
leading zeros). This was a design decision Paul and I made at the
time. Some OS vendors have incorrectly extended it.


In message <>, Greg Whynott writ

Mostly the input is done by a library implementing the Posix
version of fprintf or fscanf.

  10 = 10, 0xa, 012
010 = 8, 0x8, 010
0x10 = 16, 0x10, 020

and there are others. google( fscanf )

Mostly everything understands fscanf syntax.


Greg Whynott wrote:

You're entering land of weird, misdocumentation and bugs.