There's a Stack Overflow post from about a year ago asking something similar (this post).

The main reason is how inet_aton() (man page) converts the octets into the binary address.

a.b.c.d

Each of the four numeric parts specifies a byte of the address; the bytes are assigned in left-to-right order to produce the binary address.

a.b.c

Parts a and b specify the first two bytes of the binary address. Part c is interpreted as a 16-bit value that defines the rightmost two bytes of the binary address. This notation is suitable for specifying (outmoded) Class B network addresses.

a.b

Part a specifies the first byte of the binary address. Part b is interpreted as a 24-bit value that defines the rightmost three bytes of the binary address. This notation is suitable for specifying (outmoded) Class C network addresses.

a

The value a is interpreted as a 32-bit value that is stored directly into the binary address without any byte rearrangement.

This isn't defined by POSIX.anything - but it is available pretty widely.


It's a relic from the old days of classful addressing. 127.1 means network 127, host 1. (And, yes, 127.257 is legal because network 127 can have more than 256 hosts.