Chapter 2

IPv4 & IPv6

Addresses, notation, loopback, and dual-stack.

Learning objectives

  • Write IPv4 dotted decimal and identify network vs host portions
  • Read compressed IPv6 notation
  • Know loopback, link-local, and when dual-stack matters

IPv4 — four octets

An IPv4 address is four numbers 0–255, written 192.168.1.10. Each number is 8 bits — 32 bits total. Roughly 4.3 billion addresses exist; that is not enough for every device on Earth, which is why NAT and IPv6 matter.

Special IPv4 ranges

Address / rangePurpose
127.0.0.1Loopback — “this machine” (localhost)
10.0.0.0/8Private (RFC 1918)
172.16.0.0/12Private
192.168.0.0/16Private — common on home/small office routers
203.0.113.0/24Documentation (TEST-NET-3) — used in textbooks

IPv6 — 128 bits

IPv6 uses eight groups of four hex digits: 2001:db8:acad:1::10. Double colon (::) compresses consecutive zero groups once per address.

Workshop Co.’s Swift Host VPS might have:

  • IPv4: 203.0.113.10
  • IPv6: 2001:db8:113::10 (example documentation prefix)
Dual-stack

Many Canadian hosts run dual-stack — both IPv4 and IPv6. DNS can publish A and AAAA records. If only A exists, IPv6-only clients (rare today) cannot connect.

Worked example — shop PC address

Workshop Co.’s office PC gets 192.168.10.50 from the router. The subnet mask 255.255.255.0 (/24) means the first three octets are the network (192.168.10.0) and the last octet identifies the host (.1–.254 usable).

IPv4: 192.168.10.50
Mask: 255.255.255.0  (/24)
      ────────────────
Network: 192.168.10.0
Host:                  .50

Try it yourself — expand IPv6

Expand 2001:db8::1 to full eight-group form.

Answer

2001:0db8:0000:0000:0000:0000:0000:0001

Which is which?

Classify each: public routable, private, loopback, documentation.

  1. 10.5.5.1
  2. 203.0.113.10
  3. 127.0.0.1
  4. 198.51.100.44 (Workshop Co. WAN)
Answer
  1. Private
  2. Documentation (not routed on public internet)
  3. Loopback
  4. Public routable (TEST-NET-2 documentation block in examples — treat as their ISP-assigned public IP in our lab story)

Quick quiz

  1. How many bits in an IPv4 address?
  2. What does ::1 mean in IPv6?
  3. Why do we still use IPv4 if IPv6 exists?
Answers
  1. 32 bits (4 octets × 8).
  2. IPv6 loopback — equivalent to 127.0.0.1.
  3. Legacy systems, NAT workaround, and gradual migration — dual-stack is the transition norm.