How Does Ping 1.1 Convert to Ping 1.0.0.1?

ipv4

I need the rules for these ip address shorthands.

C:\Users\avina>ping 1.1

Pinging 1.0.0.1 with 32 bytes of data:
Reply from 1.0.0.1: bytes=32 time=3ms TTL=58
Reply from 1.0.0.1: bytes=32 time=4ms TTL=58
Reply from 1.0.0.1: bytes=32 time=4ms TTL=58
Reply from 1.0.0.1: bytes=32 time=5ms TTL=58

Ping statistics for 1.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 3ms, Maximum = 5ms, Average = 4ms

Best Answer

This is an old relic from the days of classful IPv4 networks.

When you had no subnetting, just exactly one class-B network with 2 octets for the host address, in some cases it would have been convenient to just use a linear numbering 0-65535 (0000h-FFFFh) for all your hosts, instead of two separate numbers. (At least that's what I assume the reason was.)

So the BSD networking software would accept x.y.(z*256+t) as alternative way of writing class-B addresses, in addition to the usual x.y.z.t. For example the address 128.42.1.6 could be written as "128.42.262" instead.

The same also worked for class-A addresses as x.(y*65536+z*256+t) – for example, the address 10.1.33.27 could be written as "10.74011".

(As a side note, for some reason it would also accept the numbers in octal and hex. Actually it gets clearer if you write the above examples in hex: 10.1.33.27 is "0xA.0x1.0x21.0x1B", and 10.74011 is "0xA.0x1211B".)

This survived in many systems which faithfully reproduced the same IP address parsing code, including Windows or Linux (and only recently purged from OpenBSD).

This Super User post describes it in more detail: https://superuser.com/revisions/486904/3

Related Topic