IPv4 and IPv6: Addressing and Subnets
What This Concept Is
IP addresses identify hosts (more precisely, interfaces) at the network layer. There are two versions in active use:
- IPv4: 32 bits, written as four dotted decimals. Example:
10.0.24.53. - IPv6: 128 bits, written as eight hextets separated by colons. Example:
2001:0db8:85a3::8a2e:0370:7334.
Addresses do not stand alone. They are always paired with a prefix length that says how many of the leading bits identify the network and how many identify the host:
10.0.24.53/20means the first 20 bits are the network, the last 12 are the host.2001:db8:85a3::/48means the first 48 bits are the network.
This split is how routing works at all. Routers do not store every host; they store network prefixes.
Why It Matters Here
Subnetting is the first real reasoning skill in networking. You will use it to:
- design VPCs and home/lab networks
- read firewall rules and routing tables
- understand why a service is "reachable from one subnet but not another"
- debug overlap and conflict between private address ranges
Concrete Example
Take 10.0.24.53/20.
/20means the network mask is255.255.240.0.10.0.24.53in binary has network bits00001010.00000000.0001and host bits0000.00110101.- Network address: zero the host bits:
10.0.16.0. - Broadcast address: set all host bits:
10.0.31.255. - Usable host range:
10.0.16.1through10.0.31.254(subtract network and broadcast). - Is
10.0.33.10in this subnet? Its first 20 bits differ from10.0.16.0/20, so no.
IPv6 avoids broadcast entirely and uses much larger prefixes (/64 is the common subnet size), but the same prefix-match mechanic applies.
Common Confusion / Misconception
"Subnet mask and prefix length are different concepts." They are two notations for the same thing: /24 is 255.255.255.0 is 24 leading ones.
"IPv6 is just bigger IPv4." The address space is bigger, but IPv6 also removes broadcast, uses link-local addresses by default, and handles neighbor discovery differently. Treat it as a sibling protocol, not a patch.
How To Use It
For any CIDR prefix A.B.C.D/N:
- Compute the mask:
Nleading ones, rest zero. - AND the address with the mask to get the network address.
- OR the network with the inverse mask to get the broadcast.
- Usable hosts are everything strictly between.
- A second address is "in the same subnet" iff ANDing both with the mask gives the same result.
Do the first few by hand. After that, memorize the common masks (/8, /16, /24, /20, /28, /30).
Check Yourself
- How many usable host addresses does
/24allow? What about/30?/28? - Why is
/31legal for point-to-point links despite having no broadcast? - What does
fe80::/10mean in IPv6 and why should you not route packets to it? - Why are
10.0.0.0/8,172.16.0.0/12, and192.168.0.0/16reserved, and what use cases do they cover? - Why does IPv6 normally use a
/64subnet, and what feature of IPv6 depends on the host part being 64 bits?
Special Address Ranges Worth Memorizing
| Range | Meaning |
|---|---|
0.0.0.0/8 | "this network" -- often used as a wildcard in bind |
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | RFC 1918 private IPv4 |
127.0.0.0/8 | loopback |
169.254.0.0/16 | IPv4 link-local (no DHCP) |
224.0.0.0/4 | IPv4 multicast |
::1/128 | IPv6 loopback |
fe80::/10 | IPv6 link-local |
fc00::/7 | IPv6 unique-local |
ff00::/8 | IPv6 multicast |
Knowing these on sight prevents an entire category of "why isn't this reachable" confusion.
Mini Drill or Application
For each CIDR, compute: network, broadcast (if IPv4), usable range, and number of usable hosts.
192.168.1.100/24172.16.5.200/2010.20.30.40/28203.0.113.65/26
Then, for 10.0.24.53/20, decide subnet membership for 10.0.16.1, 10.0.31.254, 10.0.32.0, 10.0.47.10.