IPv4 (Internet Protocol version 4) and IPv6 (Internet Protocol version 6) are the two versions of the Internet Protocol in active use. IPv4 has powered the internet since 1983 but its address space is exhausted. IPv6 was designed to replace it with a vastly larger address space and a simplified architecture.
TL;DR — IPv4 uses 32-bit addresses (about 4.3 billion total), written as four decimal numbers (e.g., 192.0.2.1). IPv6 uses 128-bit addresses (340 undecillion total), written in hexadecimal (e.g., 2001:db8::1). IANA declared IPv4 exhaustion in 2011. IPv6 eliminates NAT, simplifies the packet header, mandates IPsec support, and enables auto-configuration without DHCP. As of 2026, approximately 40% of global internet traffic uses IPv6. The two protocols are not directly compatible — networks run both simultaneously using dual-stack.
Address structure comparison
IPv4 address format
- Length: 32 bits
- Notation: Four decimal octets separated by dots
- Example:
203.0.113.45 - Total addresses: 2³² = 4,294,967,296 (~4.3 billion)
In binary: 11001011.00000000.01110001.00101101
IPv6 address format
- Length: 128 bits
- Notation: Eight groups of four hexadecimal digits separated by colons
- Example:
2001:0db8:85a3:0000:0000:8a2e:0370:7334 - Shortened:
2001:db8:85a3::8a2e:370:7334 - Total addresses: 2¹²⁸ ≈ 3.4 × 10³⁸ (340 undecillion)
IPv6 shortening rules:
- Leading zeros in each group can be omitted:
0db8→db8 - One consecutive sequence of all-zero groups can be replaced with
:::0000:0000→::
Side-by-side comparison
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address length | 32 bits | 128 bits |
| Address space | ~4.3 billion | ~340 undecillion |
| Notation | Decimal (192.168.1.1) | Hexadecimal (2001:db8::1) |
| Header size | 20–60 bytes (variable) | Fixed 40 bytes |
| NAT required | Yes (addresses exhausted) | No |
| Auto-configuration | DHCP | SLAAC (Stateless Address Autoconfiguration) |
| Security | IPsec optional | IPsec mandatory |
| Broadcast | Yes | No (multicast replaces broadcast) |
| Fragmentation | At routers and hosts | Hosts only (Path MTU Discovery) |
| Checksum | In header | Removed (handled by upper layers) |
| Adoption (2026) | ~60% of traffic | ~40% of traffic |
Why IPv4 addresses ran out
The internet in 1983 had fewer than 1,000 connected hosts. IPv4’s 4.3 billion addresses seemed inexhaustible. By the early 2000s, explosive growth in internet-connected devices made exhaustion inevitable.
Key milestones:
- 1992 — IETF recognized that IPv4 would run out and began designing IPv6
- 2011 — IANA allocated the last blocks of IPv4 addresses to the Regional Internet Registries
- 2011–2015 — Regional registries (ARIN, RIPE NCC, APNIC) exhausted their own pools
- Today — IPv4 addresses are traded on secondary markets; IPv4 /24 blocks sell for approximately $50–60 per address
NAT extended IPv4’s life by letting thousands of devices share a single public IP, but it introduced complexity, broke end-to-end connectivity, and is a workaround, not a solution.
IPv6 header vs IPv4 header
The IPv6 header is simpler than IPv4’s despite the larger addresses.
IPv4 header fields (20 bytes minimum)
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | IP version (4) |
| IHL | 4 bits | Header length |
| DSCP/ECN | 8 bits | Quality of service |
| Total Length | 16 bits | Packet length |
| Identification | 16 bits | Fragmentation |
| Flags | 3 bits | Fragmentation control |
| Fragment Offset | 13 bits | Fragmentation |
| TTL | 8 bits | Hop limit |
| Protocol | 8 bits | Next layer protocol |
| Header Checksum | 16 bits | Error checking |
| Source Address | 32 bits | Source IP |
| Destination Address | 32 bits | Destination IP |
IPv6 header fields (40 bytes, fixed)
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | IP version (6) |
| Traffic Class | 8 bits | QoS (equivalent to DSCP) |
| Flow Label | 20 bits | Identifies a traffic flow |
| Payload Length | 16 bits | Length of data after header |
| Next Header | 8 bits | Next layer protocol (replaces Protocol field) |
| Hop Limit | 8 bits | Replaces TTL |
| Source Address | 128 bits | Source IPv6 address |
| Destination Address | 128 bits | Destination IPv6 address |
IPv6 removed the header checksum (upper layers handle error detection), fragmentation fields (hosts perform Path MTU Discovery instead), and the IHL field (header is fixed-size). The fixed 40-byte header is easier for routers to process at line rate.
Key IPv6 improvements
No NAT
Every IPv6 device gets a globally unique public address. End-to-end connectivity is restored — a device can be directly reached without port forwarding or NAT traversal workarounds.
SLAAC — Stateless Address Autoconfiguration
IPv6 devices can generate their own addresses without DHCP by combining the network prefix (from the router’s Router Advertisement) with a host identifier derived from the device’s MAC address (EUI-64) or a random value (privacy extensions). This eliminates the need for a DHCP server for basic connectivity.
Mandatory IPsec
IPv6 requires IPsec support in all implementations. IPv4 treated IPsec as optional. In practice, most traffic on both versions relies on TLS at the application layer rather than IPsec at the network layer, but the mandate reflects IPv6’s security-first design.
No broadcast
IPv4 broadcast sends a packet to every device on a subnet. IPv6 replaces broadcast with multicast — packets are sent to a specific group of interested devices rather than everyone. This reduces unnecessary traffic processing on devices not interested in the message.
IPv6 address types
| Type | Example | Purpose |
|---|---|---|
| Global unicast | 2001:db8::/32 | Globally routable (equivalent to public IPv4) |
| Link-local | fe80::/10 | Communication within a single network segment |
| Unique local | fc00::/7 | Private addressing (equivalent to RFC 1918) |
| Loopback | ::1/128 | Localhost (equivalent to 127.0.0.1) |
| Multicast | ff00::/8 | One-to-many delivery to a group |
| Anycast | — | One address, multiple potential receivers (nearest one responds) |
Migration strategies
Dual-stack
The most common approach. Devices and networks run both IPv4 and IPv6 simultaneously. A device has both an IPv4 and IPv6 address and prefers IPv6 when available (RFC 6724 defines preference rules).
Dual-stack requires no translation overhead but doubles address management complexity.
Tunneling
IPv6 packets are encapsulated inside IPv4 packets to cross IPv4-only infrastructure. Techniques include 6in4 (protocol 41), 6to4, and ISATAP. Tunneling adds overhead and can introduce MTU issues.
NAT64 / DNS64
A translation mechanism that allows IPv6-only clients to communicate with IPv4-only servers. The NAT64 gateway translates between IPv6 and IPv4 packet formats. DNS64 synthesizes AAAA records from A records for IPv4-only hosts, so IPv6 clients receive an IPv6 address to connect to.
What changes for developers
Most application code is insulated from the IPv4/IPv6 difference by operating systems and libraries. However, developers need to be aware of:
- Socket programming: Bind to
0.0.0.0for IPv4-only or::for dual-stack. UseAF_INET6withIPV6_V6ONLYcorrectly. - IP address storage: IPv6 addresses do not fit in fields sized for IPv4 (e.g., a 15-character
VARCHARforxxx.xxx.xxx.xxxfails for IPv6). Use a minimum of 39 characters or a purpose-built IP column type. - URL format: IPv6 addresses in URLs must be enclosed in brackets:
http://[2001:db8::1]:8080/path - Logging: Ensure log parsers and SIEM tools handle IPv6 address formats.
- Firewall rules: Separate firewall rules are needed for IPv4 and IPv6 — a rule for
0.0.0.0/0does not cover IPv6 traffic.
Frequently asked questions
What is the main difference between IPv4 and IPv6? IPv4 uses 32-bit addresses (4.3 billion total) while IPv6 uses 128-bit addresses (340 undecillion total). IPv4 addresses are nearly exhausted, requiring NAT for address sharing. IPv6 provides enough addresses for every device to have a globally unique public IP, eliminating NAT and restoring end-to-end connectivity.
Why is IPv6 adoption so slow if IPv4 is exhausted? IPv4 and IPv6 are not directly compatible, so both protocols must run in parallel (dual-stack) during the transition. Upgrading all infrastructure, software, and hardware to support IPv6 takes time and investment. NAT extended IPv4’s practical life long enough that many organizations deprioritized migration. As of 2026, approximately 40% of internet traffic uses IPv6.
Can IPv6 and IPv4 communicate directly? No. IPv6 and IPv4 are incompatible at the network layer. Communication between IPv6-only and IPv4-only devices requires a translation mechanism such as NAT64, which converts between the two packet formats at a gateway.
What is dual-stack? Dual-stack means a device or network supports both IPv4 and IPv6 simultaneously. The device has an address in each version and prefers IPv6 when connecting to destinations that support it. Dual-stack is the most common migration approach because it maintains compatibility with IPv4-only infrastructure while adopting IPv6.
Does IPv6 make networks faster? IPv6’s fixed 40-byte header is simpler for routers to process than IPv4’s variable-length header, which can provide minor throughput improvements at line rate. IPv6 also enables Path MTU Discovery more reliably, reducing fragmentation. The practical performance difference for most applications is negligible.
What is SLAAC? SLAAC (Stateless Address Autoconfiguration) allows IPv6 devices to generate their own IP addresses without a DHCP server. The device combines the network prefix advertised by the router with a locally generated host identifier to produce a full IPv6 address. SLAAC simplifies network administration by removing the dependency on centralized address assignment.
Is IPv6 more secure than IPv4? IPv6 mandates IPsec support in all implementations, which IPv4 makes optional. However, most traffic on both protocol versions uses TLS at the application layer for encryption. The elimination of NAT in IPv6 restores end-to-end connectivity, which is architecturally cleaner, but also means devices are directly reachable — making proper firewall configuration more important.