When I try to ping the IP address I have no response since nothing exist in the network with that IP address.

However if I try to ping instead another IP address responds:

root@everest:/root# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=253 time=0.732 ms
64 bytes from icmp_seq=2 ttl=253 time=0.695 ms
64 bytes from icmp_seq=3 ttl=253 time=0.659 ms
64 bytes from icmp_seq=4 ttl=253 time=0.705 ms

Considering that is a Lexmark E120n printer what could be the origin of this strange problem?


That behavior is actually due to a normal feature of ping and has no relation to your actual hardware.

Indeed, prefixing the IP address (or part of it) with a leading zero will cause the number to be interpreted as octal.

So 057 means 57 in base 8 which is 47. Thus ping will send the ICMP query to the machine located at address and therefore get an answer from it.

Note that you can also ping adresses in hexadecimal, by using the 0x prefix instead of just 0.

Edit : As many comments suggest, this feature is actually not specific to ping and can be found in many CLI softwares manipulating IP addresses.

| improve this answer | |
  • Whoa! Thank you! My heart stopped for a bunch of minutes :-) – PsyStyle May 19 '15 at 11:53
  • 4
    Not just ping. Lots of things do that. – Jenny D May 19 '15 at 12:02
  • 1
    Bash treats all "integers" like that askubuntu.com/questions/621500/… – Tim May 19 '15 at 17:02

Ping, like many other unix programs, use the C libraries on your unix system for name resolution. One of the functions used is inet_aton.

The man page for inet_aton says:

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; otherwise, the number is interpreted as decimal).

So when you're using a leading zero, the number is interpreted as a octal. Thus, 57 = 047 = 0x39.

| improve this answer | |
  • I noticed even Windows behaves the same. Thank you for your detailed answer! – PsyStyle May 19 '15 at 12:07
  • @PsyStyle You're welcome! It's a standard notation for numbers, across a wide spectrum of operating systems and programming languages. – Jenny D May 19 '15 at 12:38
  • "So when you're using a leading zero, the number is interpreted as a decimal.". I think this is a typo, you meant interpreted as octal right? – Cruncher May 19 '15 at 12:39
  • 1
    Thanks @Cruncher. I blame too high a concentration of blood in my caffeine stream. – Jenny D May 19 '15 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.