3

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

2 Answers 2

3

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

1

This follows the (rarely used) convention that middle 0 octets can be omitted in writing - this is much more prominent in IPv6 with the double :: notation.

1.1 expands to 1.0.0.1 like e.g. 127.1 expands to 127.0.0.1. Likewise a.b.c expands to a.b.0.c and even just a expands to 0.0.0.a (consistent with the unsigned 32-bit notation).

In reality, an IPv4 address is an unsigned 32-bit integer. The common a.b.c.d notation is really a<<24|b<<16|c<<8|d. When only a.b is used it's a<<24|b and a.b.c is really a<<24|b<<16|c. (Thx grawity!)

2
  • 3
    No, a.b.c expands to a.b.(c / 256).(c % 256). Feb 16, 2019 at 12:59
  • 1
    @grawity You're correct - this is even more obscure than the a.b notation. Likewise a.b expands to a.(b/65536).((b%65536)/256).(b%256). I don't think anyone wants to use that...
    – Zac67
    Feb 16, 2019 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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