Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IPv6 and the Future

IPv6 was designed to solve IPv4’s address exhaustion problem—and to fix several other shortcomings along the way. With 128-bit addresses, IPv6 provides enough addresses for every grain of sand on Earth to have its own IP… many times over.

Why IPv6?

The primary driver was address space:

IPv4: 2³² = 4.3 billion addresses
IPv6: 2¹²⁸ = 340 undecillion addresses

             340,282,366,920,938,463,463,374,607,431,768,211,456

That's 340 trillion trillion trillion addresses.
Or about 50 octillion addresses per human alive today.

But IPv6 also addressed other IPv4 limitations:

  • No more NAT required (enough addresses for everyone)
  • Simplified header (faster routing)
  • Built-in security (IPsec)
  • Better multicast support
  • Stateless address autoconfiguration

IPv6 Address Format

An IPv6 address is 128 bits, written as eight groups of four hexadecimal digits:

Full form:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
└──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘ └──┘
  │    │    │    │    │    │    │    │
  ▼    ▼    ▼    ▼    ▼    ▼    ▼    ▼
Each group = 16 bits (4 hex digits)
8 groups × 16 bits = 128 bits

Address Shortening Rules

IPv6 addresses can be shortened for readability:

Rule 1: Remove leading zeros in each group

2001:0db8:0042:0000:0000:0000:0000:0001
     ↓
2001:db8:42:0:0:0:0:1

Rule 2: Replace one sequence of all-zero groups with ::

2001:db8:42:0:0:0:0:1
           ↓
2001:db8:42::1

Important: :: can only appear once per address (otherwise it’s ambiguous).

Examples

Full                                    Shortened
────────────────────────────────────────────────────────────
2001:0db8:0000:0000:0000:0000:0000:0001  2001:db8::1
0000:0000:0000:0000:0000:0000:0000:0001  ::1 (loopback)
0000:0000:0000:0000:0000:0000:0000:0000  :: (unspecified)
fe80:0000:0000:0000:0215:5dff:fe00:0000  fe80::215:5dff:fe00:0
2001:0db8:85a3:0000:0000:8a2e:0370:7334  2001:db8:85a3::8a2e:370:7334

The IPv6 Header

IPv6’s header is simpler than IPv4’s—fixed at 40 bytes with no options in the base header:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
├───────┬───────────────┬───────────────────────────────────────┤
│Version│ Traffic Class │              Flow Label               │
├───────┴───────────────┼───────────────────┬───────────────────┤
│      Payload Length   │   Next Header     │    Hop Limit      │
├───────────────────────┴───────────────────┴───────────────────┤
│                                                               │
│                       Source Address                          │
│                       (128 bits)                              │
│                                                               │
├───────────────────────────────────────────────────────────────┤
│                                                               │
│                    Destination Address                        │
│                       (128 bits)                              │
│                                                               │
└───────────────────────────────────────────────────────────────┘

Key Differences from IPv4

IPv4IPv6
Variable header (20-60 bytes)Fixed header (40 bytes)
Header checksumNo checksum (relies on link layer)
Fragmentation in headerExtension headers
Options in headerExtension headers

Extension Headers

IPv6 uses extension headers for optional features. They chain together:

┌──────────────┬────────────────┬──────────────┬─────────────┐
│ IPv6 Header  │  Hop-by-Hop    │  Destination │    TCP      │
│ Next: Hop-by │  Next: Dest    │  Next: TCP   │   Segment   │
│     -Hop     │   Options      │              │             │
└──────────────┴────────────────┴──────────────┴─────────────┘

Common Extension Headers:
- Hop-by-Hop Options (processed by every router)
- Routing (specify intermediate routers)
- Fragment (for packet fragmentation)
- Authentication Header (IPsec)
- Encapsulating Security Payload (IPsec encryption)
- Destination Options (for destination only)

Address Types

IPv6 has three address types (no broadcast!):

┌─────────────────────────────────────────────────────────────┐
│                    IPv6 Address Types                       │
├─────────────────────────────────────────────────────────────┤
│  Unicast      One-to-one communication                      │
│               Single sender, single receiver                │
│                                                             │
│  Multicast    One-to-many communication                     │
│               Single sender, multiple receivers             │
│               (Replaces broadcast)                          │
│                                                             │
│  Anycast      One-to-nearest communication                  │
│               Delivered to closest node in a group          │
│               (Same address on multiple nodes)              │
└─────────────────────────────────────────────────────────────┘

Special Address Prefixes

Prefix              Type                    Purpose
──────────────────────────────────────────────────────────────
::1/128             Loopback                Local host (localhost)
::/128              Unspecified             No address assigned
fe80::/10           Link-local              Same network only
fc00::/7            Unique local            Private addresses
ff00::/8            Multicast               Group communication
2000::/3            Global unicast          Public internet
::ffff:0:0/96       IPv4-mapped             IPv4 in IPv6 format
64:ff9b::/96        IPv4-IPv6 translation   NAT64

Every IPv6 interface automatically gets a link-local address starting with fe80:::

Interface: eth0
Link-local: fe80::1a2b:3c4d:5e6f:7890

These addresses:
- Auto-generated from MAC address (or random)
- Valid only on local network segment
- Not routed beyond local link
- Always present, even without DHCP/manual config

Global Unicast Addresses

Public IPv6 addresses typically start with 2 or 3:

2001:db8:1234:5678:9abc:def0:1234:5678
└───────────┬──────────┘└────────┬──────┘
      Routing Prefix        Interface ID
    (Network portion)     (Host portion)

Typical allocation:
/48  - Organization gets this from ISP
/64  - Single subnet (standard recommendation)

Address Autoconfiguration

IPv6 supports Stateless Address Autoconfiguration (SLAAC)—devices can configure their own addresses without DHCP:

1. Interface comes up
   ↓
2. Generate link-local address (fe80::...)
   ↓
3. Router sends Router Advertisement (RA)
   Contains: Network prefix (e.g., 2001:db8:1::/64)
   ↓
4. Host generates global address:
   Prefix from RA + Interface ID = Global Address
   2001:db8:1::1a2b:3c4d:5e6f:7890/64
   ↓
5. Host verifies uniqueness (DAD - Duplicate Address Detection)
   ↓
6. Address is ready to use!

DHCPv6 is available for networks needing more control.

IPv4 to IPv6 Transition

The world is slowly transitioning. Several mechanisms help:

Dual Stack

Devices run both IPv4 and IPv6:

┌─────────────────────────────────────┐
│            Application              │
├──────────────┬──────────────────────┤
│     IPv4     │        IPv6          │
├──────────────┼──────────────────────┤
│   Network Interface                 │
└─────────────────────────────────────┘

Device has both:
  IPv4: 192.168.1.100
  IPv6: 2001:db8::1234

Tunneling

IPv6 packets wrapped in IPv4 to cross IPv4-only networks:

┌───────────────────────────────────────────────────────┐
│ IPv4 Header                                           │
│ (src: 203.0.113.1, dst: 198.51.100.1)                │
├───────────────────────────────────────────────────────┤
│ ┌───────────────────────────────────────────────────┐ │
│ │ IPv6 Header                                       │ │
│ │ (src: 2001:db8::1, dst: 2001:db8::2)              │ │
│ ├───────────────────────────────────────────────────┤ │
│ │ Original Data                                     │ │
│ └───────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────┘

NAT64/DNS64

Allows IPv6-only devices to reach IPv4 servers:

IPv6-only Client                NAT64 Gateway              IPv4 Server
      │                              │                          │
      │─────IPv6 packet──────────────>│                          │
      │  dst: 64:ff9b::93.184.216.34 │                          │
      │                              │──────IPv4 packet────────>│
      │                              │  dst: 93.184.216.34      │
      │                              │                          │
      │                              │<─────IPv4 response───────│
      │<─────IPv6 response───────────│                          │

Working with IPv6

Command Line

# Show IPv6 addresses
$ ip -6 addr show
2: eth0: <BROADCAST,MULTICAST,UP>
    inet6 2001:db8::1/64 scope global
    inet6 fe80::1/64 scope link

# Ping IPv6
$ ping6 ::1
$ ping -6 google.com

# Trace route
$ traceroute6 google.com

# DNS lookup
$ dig AAAA google.com

In URLs

IPv6 addresses in URLs must be bracketed:

http://[2001:db8::1]:8080/path
       └─────────────┘
       IPv6 address in brackets

Without brackets, colons are ambiguous:
http://2001:db8::1:8080  ← Is 8080 the port or part of address?

Python

import ipaddress

# Parse IPv6
ip = ipaddress.ip_address('2001:db8::1')
print(ip.is_global)       # True
print(ip.is_link_local)   # False
print(ip.exploded)        # 2001:0db8:0000:0000:0000:0000:0000:0001

# Network operations
net = ipaddress.ip_network('2001:db8::/32')
print(net.num_addresses)  # 79228162514264337593543950336

# Socket programming
import socket
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect(('2001:db8::1', 80))

IPv6 Adoption Status

As of recent measurements:

  • ~40% of Google traffic is over IPv6
  • Major cloud providers fully support IPv6
  • Mobile networks often IPv6-primary
  • Many ISPs support IPv6 (but not all)
Adoption varies by region:
  India:    ~70% IPv6
  USA:      ~50% IPv6
  Germany:  ~60% IPv6
  China:    ~30% IPv6
  Global:   ~40% IPv6 (and growing)

Practical Considerations

When You Need IPv6

  • Modern mobile app development
  • IoT devices (often IPv6-only)
  • Reaching IPv6-only users
  • Future-proofing infrastructure

Common Issues

“Network unreachable” to IPv6 addresses

  • Your network may not have IPv6 connectivity
  • Check: ping6 ::1 (should work - loopback)
  • Check: ping6 google.com (needs IPv6 internet)

Application doesn’t support IPv6

  • Some older software hardcodes IPv4
  • Check for IPv6/dual-stack support in dependencies

Firewall not configured for IPv6

  • IPv6 rules are often separate from IPv4
  • Don’t forget to configure both!

Summary

IPv6 solves IPv4’s address exhaustion with a vastly larger address space:

FeatureIPv4IPv6
Address size32 bits128 bits
Address formatDotted decimalColon hexadecimal
Header sizeVariable (20-60)Fixed (40)
Address configDHCP or manualSLAAC, DHCPv6, or manual
NATCommonGenerally unnecessary
IPsecOptionalBuilt-in

The transition to IPv6 is ongoing but inevitable. New projects should support both protocols.

Next, we’ll look at subnetting—how to divide networks into smaller, manageable pieces.