Skip to main content

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/20 means the first 20 bits are the network, the last 12 are the host.
  • 2001:db8:85a3::/48 means 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.

  • /20 means the network mask is 255.255.240.0.
  • 10.0.24.53 in binary has network bits 00001010.00000000.0001 and host bits 0000.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.1 through 10.0.31.254 (subtract network and broadcast).
  • Is 10.0.33.10 in this subnet? Its first 20 bits differ from 10.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:

  1. Compute the mask: N leading ones, rest zero.
  2. AND the address with the mask to get the network address.
  3. OR the network with the inverse mask to get the broadcast.
  4. Usable hosts are everything strictly between.
  5. 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

  1. How many usable host addresses does /24 allow? What about /30? /28?
  2. Why is /31 legal for point-to-point links despite having no broadcast?
  3. What does fe80::/10 mean in IPv6 and why should you not route packets to it?
  4. Why are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 reserved, and what use cases do they cover?
  5. Why does IPv6 normally use a /64 subnet, and what feature of IPv6 depends on the host part being 64 bits?

Special Address Ranges Worth Memorizing

RangeMeaning
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/16RFC 1918 private IPv4
127.0.0.0/8loopback
169.254.0.0/16IPv4 link-local (no DHCP)
224.0.0.0/4IPv4 multicast
::1/128IPv6 loopback
fe80::/10IPv6 link-local
fc00::/7IPv6 unique-local
ff00::/8IPv6 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.

  1. 192.168.1.100/24
  2. 172.16.5.200/20
  3. 10.20.30.40/28
  4. 203.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.

Read This Only If Stuck