ping 0xCAFECAFE and shortening IPv4 addresses

Today will be about two little-known features related to IPv4 and ways of writing IPv4 addresses.

Let us start from the end of the title: shortened IPv4 notation. In IPv6 we can omit a sequence of zeros; something similar can also be done in IPv4. For example, by running:

ping 10.2

we query the address 10.0.0.2, and:

ping 10.1.2

queries 10.1.0.2, exactly as in the screenshot below.

IPv4 address shortening and alternative notations.

While writing this, I am wondering whether this really is a feature… especially since I discovered it because of a bug in a script…

And the second “feature”: hexadecimal notation for IPv4 addresses. I wonder what happens if we try to run:

ping 0xCAFECAFE

;-))))

And the third ?feature?… unfortunately I was not able to make this one work: octal notation. In theory, according to the RFCs, IPv4 addresses can also be provided in octal form… but it seems Windows no longer respects that notation.