Binary and octets
Why does no number in an IP address go above 255?
An IPv4 address is 32 bits in four octets of 8 bits; each octet is written in decimal, 0 to 255.
An address like one nine two, one six eight, ten, seventy-seven looks like four numbers. To a machine it is one row of bits. Thirty-two of them, in four groups of eight. Each group is called an octet, and is written as an ordinary number. Take the last octet. Each of its eight bits has a place value: one hundred and twenty-eight, sixty-four, and so on down to one. Add the place values where the bit is one: sixty-four, eight, four and one make seventy-seven. All eight bits set would make two hundred and fifty-five, so that is as high as an octet goes.
IPv4 addresses and masks
The mask draws one line: network on the left, host on the right
An IPv4 address is 32 bits. The subnet mask (or /prefix) marks how many belong to the network; the rest number the hosts.
Every IPv4 address does two jobs. Here is one nine two dot one six eight dot ten dot seventy-seven, as thirty-two bits. Its mask, slash twenty-six, is twenty-six ones followed by six zeros. Where the mask has ones, the address names the network: one nine two dot one six eight dot ten dot sixty-four. Where it has zeros, it names a host on that network. Six host bits make sixty-four addresses. The first is the network, the last is the broadcast, and sixty-two are left for devices.
IPv4 addresses and masks · Going deeper
Classes A to E, and why they were abandoned
Classful addressing tied the mask to the first octet. CIDR lets any prefix length be used anywhere.
Special address ranges
Private, link-local and loopback ranges never reach the internet
RFC 1918 private ranges are 10/8, 172.16/12 and 192.168/16. APIPA (169.254/16) means DHCP failed; 127/8 is loopback.
Some address ranges are set aside. The three private ranges: ten slash eight, with sixteen million addresses; one seven two dot sixteen slash twelve; and one nine two dot one six eight slash sixteen. Anyone can use them internally, and routers on the internet drop them. Carriers use one hundred dot sixty-four slash ten behind their own NAT, and one six nine dot two five four is what a device gives itself when no DHCP server answers. One two seven is loopback, the machine talking to itself, and three small ranges are reserved for documentation.