Yes, that is explicitly allowed and always has been for IPv4.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Crawford, Scott
Sent: Wednesday, September 17, 2014 8:07 PM
To: [email protected]
Subject: [NTSysADM] RE: Pinging with less than 3 octets

While we're on the subject of ip address shortcuts, this is fairly interesting 
too:

Get an IP:
ping microsoft.com
Pinging microsoft.com [134.170.188.221] with 32 bytes of data:

Take each of the octets and convert them to binary:
134 = 10000110
170 = 10101010
188 = 10111100
221 = 11011101

Then, concatenate them into one long 32 bit string:
10000110 10101010 10111100 11011101

Convert that back into a single decimal number:
2259336413

And, ping it:
ping 2259336413
Pinging 134.170.188.221 with 32 bytes of data:

Or, try it in browser to get to Microsoft's page:
http://2259336413

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Michael B. Smith
Sent: Wednesday, September 17, 2014 4:43 PM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: Pinging with less than 3 octets

That was  my initial guess... a parsing shortcut.

But it appears to predate that, significantly.

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Crawford, Scott
Sent: Wednesday, September 17, 2014 5:38 PM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: Pinging with less than 3 octets

Cool. Thanks for the info. I guess if its documented, it'll prolly work for a 
while...at least til we're all v6. :)

I wonder if it had similar origins to the IPv6 double-colon shortcut.

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Michael B. Smith
Sent: Wednesday, September 17, 2014 4:15 PM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: Pinging with less than 3 octets

Very nice.

The behavior is documented on Windows:

http://msdn.microsoft.com/en-us/library/system.net.ipaddress.parse(v=vs.110).aspx

It's used for building "class-full" IP addresses. Which are obsolete. And it is 
also present in BSD-Unix and in Darwin. I sure as heck don't remember it from 
my Unix days though.

http://en.verysource.com/code/15332_1/inet_addr.c.html
http://www.opensource.apple.com/source/Libinfo/Libinfo-330/dns.subproj/inet_addr.c


From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Crawford, Scott
Sent: Wednesday, September 17, 2014 4:19 PM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] Pinging with less than 3 octets

When pinging, you can leave out the 3rd octet and windows will pad the address 
to fill the missing 3rd octet with 0. This also works if you leave out the 2nd 
and 3rd. Heck, it even works without the 1st :)

I've noticed this for quite a while, but have never seen it discussed. Can 
anyone tell me why this works? Is it in a spec? Or, just an interesting 
anomaly? I use it as a shortcut pretty often and just never bothered to 
research it much.

C:\>ping 10.1.1
Pinging 10.1.0.1 with 32 bytes of data:

C:\>ping 10.1
Pinging 10.0.0.1 with 32 bytes of data:

C:\>ping 10
Pinging 0.0.0.10 with 32 bytes of data:

Reply via email to