IPv4 & IPv6 Addressing
Layer 3 headers, CIDR subnetting, MTU fragmentation, and the transition to IPv6.
1. The IPv4 Header (20 Bytes)
The standard IPv4 header contains fields essential for routing and fragmentation.
Ver/IHL
0x45
1B
TOS
DSCP/ECN
1B
Length
Total Bytes
2B
Flags/Frag
DF/MF
4B
TTL
Time
1B
Proto
TCP=6
1B
Source IP
32-bit
4B
Dest IP
32-bit
4B
- TTL (Time To Live): Decremented by 1 at every router hop. Prevents infinite loops. 0 = Drop + Send ICMP "Time Exceeded".
- Protocol Field: Identifies payload. 1=ICMP, 6=TCP, 17=UDP, 89=OSPF.
- TOS (DSCP): Used for Quality of Service (QoS) markings.
2. Subnetting & CIDR (IPv4)
CIDR (Classless Inter-Domain Routing) allows variable-length subnet masks (VLSM), replacing legacy Class A/B/C addressing.
Private Address Space (RFC 1918)
Not routable on the public Internet. Requires NAT.
10.0.0.0/8(Large Enterprise)172.16.0.0/12(AWS/Cloud Default)192.168.0.0/16(Home/Small Business)
Subnet Mask Cheat Sheet
| CIDR | Subnet Mask | Usable Hosts | Use Case |
|---|---|---|---|
| /24 | 255.255.255.0 | 254 | Standard LAN |
| /28 | 255.255.255.240 | 14 | Small DMZ |
| /30 | 255.255.255.252 | 2 | Legacy P2P Link |
| /31 | 255.255.255.254 | 2 | Modern P2P Link (RFC 3021) |
| /32 | 255.255.255.255 | 1 | Loopback / Host Route |
3. IPv6 Fundamentals
IPv6 uses 128-bit addresses, hex notation, and a simplified header.
IPv6 Header vs IPv4
- Simpler: Fixed 40-byte header. No Checksum (rely on L2/L4). No Fragmentation fields (done by source).
- Flow Label: New field for QoS/hashing.
- Next Header: Replaces "Protocol" field. Can chain extension headers.
Address Types
- Global Unicast (2000::/3): Publicly routable.
- Link-Local (FE80::/10): Mandatory on every interface. Used for NDP, Routing Protocols. Non-routable.
- Unique Local (FC00::/7): Private (like RFC 1918).
- Multicast (FF00::/8): Replaces Broadcast entirely.
NDP (Neighbor Discovery Protocol)
Replaces ARP. Uses ICMPv6.
- Router Solicitation (RS) / Advertisement (RA): "I am a router, here is the prefix." (SLAAC).
- Neighbor Solicitation (NS) / Advertisement (NA): "Who has this IP? I do." (Address Resolution).
4. MTU & Fragmentation
MTU (Maximum Transmission Unit) is typically 1500 bytes.
- IPv4: Routers can fragment packets if DF bit is 0. High CPU cost.
- IPv6: Routers NEVER fragment. Source must perform PMTUD (Path MTU Discovery).
- PMTUD: Relies on ICMP Type 3 Code 4 (Packet Too Big). Blocking ICMP breaks the internet!
References
- RFC 791: Internet Protocol (IPv4) - The original IP specification.
- RFC 8200: Internet Protocol, Version 6 (IPv6) Specification - The modern standard for IPv6.
- RFC 1918: Address Allocation for Private Internets - Defines private IP ranges (10.x, 172.16.x, 192.168.x).
- RFC 4632: Classless Inter-domain Routing (CIDR) - The standard for VLSM and aggregation.