Sub topic 16
Living alongside IPv4
This chapter assumes you know IPv4 addressing, CIDR notation, and the IPv6 address types from earlier chapters (global unicast, link-local, unique local). IPv4 and IPv6 are separate protocols and cannot talk to each other directly. A host with only an IPv6 address cannot open a connection to a host with only an IPv4 address. Three families of techniques bridge this gap: dual stack, tunneling, and translation.
Dual stack
A dual-stack host runs IPv4 and IPv6 at the same time. Each interface has both kinds of address, and the host keeps a routing table for each. Dual stack is the preferred approach because it needs no conversion. Each connection uses one protocol from start to finish.
When a name has both an A record (IPv4) and an AAAA record (IPv6), the host must choose. The usual rule is to prefer IPv6. Many clients use "Happy Eyeballs" (RFC 8305). They start an IPv6 attempt, and if it has not succeeded after a short delay, they start an IPv4 attempt and keep whichever connects first. This hides broken IPv6 paths from users.
The cost of dual stack is that you run two networks. You need two address plans, two sets of firewall rules, and two sets of monitoring.
Tunneling
Tunneling carries IPv6 packets inside IPv4 packets. This lets IPv6 islands reach each other across an IPv4-only network. The IPv4 header uses protocol number 41, which means "IPv6 inside".
- Manual (configured) tunnels connect two fixed endpoints. Tunnel brokers use them to give a customer IPv6 connectivity.
- 6in4 is the simple encapsulation used by those tunnels.
- 6to4 and Teredo were automatic tunnels. They are now deprecated because they were unreliable and hard to secure. Do not build new designs on them.
Tunnels add header overhead, so the usable MTU is smaller. A 6in4 tunnel over a 1500-byte link normally leaves 1480 bytes for the IPv6 packet. A wrong MTU is a common cause of connections that start but stall.
Translation
Translation converts packets from one protocol to the other. It is used when a client has only IPv6 but the server has only IPv4.
- NAT64 is a gateway that maps IPv6 packets to IPv4 packets. It uses the well-known prefix
64:ff9b::/96. - DNS64 is a DNS server feature. When a name has no
AAAArecord, it builds one by placing the IPv4 address inside the NAT64 prefix.
The Python ipaddress module shows how an IPv4 address is embedded:
import ipaddress
v4 = ipaddress.IPv4Address("192.0.2.33")
prefix = int(ipaddress.IPv6Address("64:ff9b::"))
synth = ipaddress.IPv6Address(prefix | int(v4))
print(synth) # 64:ff9b::c000:221The last 32 bits of the IPv6 address are the IPv4 address. A client sends to 64:ff9b::c000:221, and the NAT64 gateway forwards the traffic to 192.0.2.33.
Choosing an approach
| Approach | Best for | Main drawback |
|---|---|---|
| Dual stack | Most networks | Two networks to run |
| Tunneling | Reaching IPv6 over an IPv4-only link | Lower MTU, extra hop |
| NAT64 and DNS64 | IPv6-only networks reaching IPv4 content | Breaks IPv4 literals |
Exercise
A client on an IPv6-only network uses DNS64 and NAT64 with the prefix 64:ff9b::/96. The server has only the IPv4 address 198.51.100.7. What IPv6 address does DNS64 return?
Show answer
198.51.100.7 is c6.33.64.07 in hex, which is c633:6407. DNS64 returns 64:ff9b::c633:6407.