IP addresses and subnetting
Read IPv4 addresses the way routers do — as 32 bits split into a network part and a host part — and learn to size, split and reason about subnets with confidence.
In this lecture you will
- Read an IPv4 address in dotted-decimal and binary form
- Explain CIDR notation and the subnet mask
- Work out a subnet’s network address, broadcast address and usable host range
- Decide whether two addresses are on the same subnet — and what a device does if they are not
Every device on an IP network needs an address, and every router makes its decisions from addresses. To design networks, configure cloud environments or read a firewall rule, you need to see an address the way a router does: as a string of bits with a boundary in the middle.
An address is 32 bits
An IPv4 address such as 10.20.30.77 is really a 32-bit number. The dotted notation just writes it as four 8-bit chunks, called octets, each shown in decimal from 0 to 255.
10 .20 .30 .77
00001010 .00010100 .00011110 .01001101
32 bits gives about 4.3 billion possible addresses — which the world ran out of years ago. That shortage is why private addresses, NAT and IPv6 exist, all of which you will meet in this course.
Network part and host part
Every address is split into two parts:
- the network part — which network the device is on (shared by everyone on the same subnet);
- the host part — which device it is within that network.
Where the split falls is given by the prefix length, written after a slash in CIDR notation. In 10.20.30.77/26, the first 26 bits are the network part and the remaining 6 bits identify the host.
The same boundary can be written as a subnet mask: 26 ones followed by 6 zeros, which in dotted form is 255.255.255.192. Older equipment and many settings screens still ask for the mask; modern tools prefer the prefix length. They mean exactly the same thing.
Try the calculator
Change the address and the prefix length and watch which bits belong to the network (teal) and which to the host (amber). Then test a second address to see whether a device would deliver to it directly or hand it to the router.
Working out a subnet by hand
The calculator does four simple things you can do yourself:
- Network address — keep the network bits, set every host bit to 0. For
10.20.30.77/26that is10.20.30.64. - Broadcast address — keep the network bits, set every host bit to 1:
10.20.30.127. A message sent here reaches every host on the subnet. - Size — a prefix of n leaves 32 − n host bits, so the subnet holds addresses. Here, .
- Usable hosts — subtract the network and broadcast addresses: 62 hosts, from
.65to.126.
A useful shortcut: in the last octet, subnets of a given size always start at multiples of that size. /26 subnets (size 64) start at .0, .64, .128 and .192 — so .77 must fall in the one starting at .64.
- One /24The 256 addresses of 192.168.10.0/24, drawn row by row. The first address names the network and the last is the broadcast address, leaving 254 for hosts.
- Two /25sMoving the boundary one bit to the right splits the block in half: .0–.127 and .128–.255. Each half again loses its first and last address.
- Four /26sTwo more network bits give four blocks of 64, starting at .0, .64, .128 and .192 — always at multiples of the block size.
- Mixed sizesA real plan gives each group what it needs: a /25 for 100 office laptops, a /26 for servers and two /27s for printers and future growth. Each block starts at a multiple of its own size.
- Cloud reservationsCloud providers reserve extra addresses in every subnet. On AWS the first four and the last are off limits, so a /28 leaves only 11 usable addresses.
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
Local or remote? How a device decides
Before sending anything, a device compares its own network part with the destination’s, using a bitwise AND with the mask:
- Same network → the destination is on the local link. The device finds its hardware address (using ARP on IPv4) and delivers the frame directly.
- Different network → the device sends the packet to its default gateway, the router, which forwards it onward.
This is why a wrong mask or gateway causes such confusing faults: a machine may try to deliver “locally” to an address that is actually remote, or send local traffic to a router that drops it.
With the correct /24 mask, the printer is local and everything else goes via the router. Now shrink the prefix to /16: the file server on 192.168.2.0/24 suddenly looks local, and the laptop waits for an ARP reply that never comes.
Private and special ranges
Some ranges are reserved and never routed on the public internet. Organizations reuse them freely inside their own networks:
- 10.0.0.0/8
- Private — about 16.7 million addresses. Common in large enterprises and cloud networks.
- 172.16.0.0/12
- Private — 172.16.0.0 to 172.31.255.255.
- 192.168.0.0/16
- Private — typical of home and small-office routers.
- 127.0.0.0/8
- Loopback — 127.0.0.1 always means “this machine”.
- 169.254.0.0/16
- Link-local — self-assigned when no DHCP server answered. Seeing one usually signals a problem.
Subnets tell a device when to hand traffic to a router. Next, we follow what the router does with it.
Key takeaways
- An IPv4 address is 32 bits; the prefix length says how many of them identify the network.
- A subnet with prefix /n contains 2^(32 − n) addresses, two of which are reserved for the network and broadcast.
- Devices compare network parts to decide whether to deliver locally or send traffic to the default gateway.
- Private ranges (10/8, 172.16/12, 192.168/16) are reused inside organizations and reach the internet through NAT.
Check your understanding
4 questions · answers explainedQ1How many usable host addresses does a /27 subnet provide?
Q2Is 192.168.1.130 inside the subnet 192.168.1.0/25?
Q3A laptop at 10.0.5.20/24 wants to reach 10.0.6.8. What does it do?
Q4Which of these is a private address that is never routed on the public internet?