Hone

Lessons · IT support · usable hosts in a subnet

How many machines fit: two to the host bits, minus two

A /n network has 32 − n host bits, so 2^(32 − n) addresses. Two of them are spoken for, the network address and the broadcast, so usable hosts = 2^(32 − n) − 2.

Hone is a place to practise a career, one idea a day. This is one of its lessons, written out in full and free to read without an account.

What it is for

A new floor is opening with 70 desks, and the plan says give it a /26. A /26 holds 62 machines. The last eight desks will not get an address, and the ticket that arrives will say 'the new floor's internet is broken' when what is broken is arithmetic done at a whiteboard three months ago.

How to think about it

Subtract the prefix from 32 to get host bits. Two to that power is the addresses. Take two off. Learn the short ladder: /24 is 254, /25 is 126, /26 is 62, /27 is 30, /28 is 14, /29 is 6, /30 is 2; each step down the prefix doubles, each step up halves. Say the unit: hosts, not addresses.

Worked example

/24 → 32 − 24 = 8 host bits → 2^8 = 256 addresses
The whole last octet is hosts. 256 numbers, 0 to 255.
Usable hosts = 256 − 2 = 254
Minus the network (.0) and the broadcast (.255).
/26 → 2^(32−26) − 2 = 64 − 2 = 62 usable hosts
Six host bits. Sixty-four addresses, sixty-two machines.
/30 → 2^2 − 2 = 2 usable hosts
Four addresses, two of them usable. Exactly what a point-to-point link between two routers needs.

Your turn

Write the usable hosts in a /28.

/28 → 2^(32−28) − 2 =  usable hosts

The trap

Forgetting the minus two, or applying it to the wrong thing. A /24 has 256 addresses and 254 hosts. On an exam that difference is one question; on a floor plan it is two desks that never come online.

Practise usable hosts in a subnet on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.