keepcalculator

06 Numbers and Powers

IPv4 to IPv6 Translation: How Packet Engines Work

Card No. 06·20265 · Updated · Standard formula, shown below

Packet conversion engines translate IPv4 to IPv6 by rewriting packet headers in real time, mapping IPv4 addresses into a reserved IPv6 prefix and translating ICMP, TCP, and UDP messages so both protocol stacks can communicate without native dual-stack support. The engine sits between an IPv6-only network and an IPv4-only destination, performing stateful NAT64-style translation plus DNS64 to synthesize AAAA records from A records. This article explains the translation mechanisms, the address-mapping math, the common pitfalls, and how to choose between translation and tunneling.

Why Translation Is Needed

IPv4 uses 32-bit addresses (about 4.3 billion), while IPv6 uses 128-bit addresses (about 340 undecillion). The internet has largely run out of new IPv4 blocks, but most servers and legacy applications still speak only IPv4. Operators deploying IPv6-only networks—especially mobile carriers and new data centers—need a way to let their users reach IPv4 content without maintaining a full dual-stack infrastructure. Translation engines bridge that gap by making IPv6 packets look like IPv4 packets (and vice versa) at the network edge.

Core Translation Methods

There are two main families of translation: stateful and stateless.

  • Stateful NAT64: The engine keeps a table mapping each IPv6 flow to a temporary IPv4 address and port. It creates the mapping on the first packet and removes it after a timeout.
  • Stateless (SIIT): The engine applies a fixed algorithmic mapping (usually 1:1) between IPv4 and IPv6 addresses, so no per-flow state is needed. This works well for server-to-server communication but consumes a whole IPv6 /96 prefix per IPv4 address.

Most commercial and open-source translation engines (e.g., Jool, Tayga, Linux kernel NAT64) implement stateful NAT64 because it scales to many users behind a small pool of public IPv4 addresses.

Address Translation Mechanics

The heart of IPv4-to-IPv6 translation is the address mapping. For stateful NAT64, the engine uses a well-known prefix (WKP) 64:ff9b::/96 defined in RFC 6052, or a network-specific prefix. The IPv4 address is appended to the prefix. For example, IPv4 192.0.2.1 becomes 64:ff9b::c000:201 (hexadecimal 192.0.2.1 = c000:0201).

When an IPv6 host sends a packet to that synthesized address, the engine:

  1. Looks up the destination in its NAT64 mapping table.
  2. Allocates an IPv4 address and port from its pool (e.g., 198.51.100.10:5000).
  3. Rewrites the IPv6 header to an IPv4 header, setting the source to the allocated IPv4 address and the destination to the real IPv4 address.
  4. Translates the transport-layer header (TCP/UDP/ICMP) and adjusts checksums.
  5. Forwards the packet to the IPv4 network.

Return packets follow the reverse path: the engine sees the IPv4 packet, looks up the destination port in its table, and rewrites it back to the original IPv6 address.

DNS64: Finding the IPv4 Address

Before any packet can be translated, the IPv6 host must know the destination’s IPv6 address. DNS64 (RFC 6147) is a companion function that runs on the DNS resolver. When a host asks for an AAAA record (IPv6) and the server only returns an A record (IPv4), DNS64 synthesizes an AAAA record by embedding the IPv4 address into the translation prefix. The host then sends packets to that synthetic address, which the translation engine recognizes and converts.

Example: A host queries example.com. The authoritative server returns A record 93.184.216.34. DNS64 returns 64:ff9b::5db8:d822 (93.184.216.34 = 5db8:d822). The host initiates a TCP connection to that IPv6 address, and the NAT64 engine translates it to IPv4.

Common Problems and Misconceptions

Translation is not transparent for every application. The most frequent issues are:

  • Embedded IP addresses in payloads: Applications like FTP or SIP that carry IP addresses in the data field break because the engine only rewrites headers. ALG (Application Layer Gateway) modules can help for some protocols, but not all.
  • Fragmentation: IPv6 routers do not fragment packets; the sender must use Path MTU Discovery. When the IPv4 path has a smaller MTU, the engine must fragment the IPv4 packet, which can cause performance issues.
  • Checksum recalculation: IPv4 headers have a checksum, IPv6 do not. The engine must compute IPv4 checksums and adjust TCP/UDP checksums when addresses change.
  • Port exhaustion: A stateful NAT64 pool of one IPv4 address has only 65,535 ports per protocol. With many users, the pool can be exhausted, so operators need multiple IPv4 addresses.
  • Misconception: Translation is transparent: Many assume any IPv4 application works over NAT64. In reality, applications that use raw sockets, IPsec, or multicast do not work without special handling.

Choosing Between Translation and Tunneling

Translation is not the only way to connect IPv6 and IPv4. Tunneling (e.g., 6in4, GRE) encapsulates IPv6 packets inside IPv4 packets, creating a virtual link. The choice depends on the scenario:

  • Translation (NAT64/DNS64): Best for connecting a large IPv6-only user base to the IPv4 internet. It does not require the IPv6 host to have any IPv4 address.
  • Tunneling: Best for connecting two isolated IPv6 networks over an IPv4 backbone, or for an IPv6 host that needs to reach an IPv6-only service through an IPv4-only network. Tunnels preserve end-to-end IPv6 semantics but add overhead and require a tunnel broker or manual configuration.

In practice, many operators use both: NAT64 for internet access and tunnels for internal IPv6 interconnection.

Performance and Cost Considerations

Translation engines add latency (typically microseconds) and consume CPU for header rewriting and state table lookups. For high-throughput environments, dedicated hardware or optimized kernel modules are used. The cost is mainly in IPv4 address pool management and the need for redundant engines to avoid a single point of failure. There is also an operational cost: monitoring NAT64 logs, handling ALG exceptions, and troubleshooting application-specific failures.

Alternatives to Translation

Besides translation and tunneling, there are other strategies:

  • Dual-stack: Run both protocols on every interface. This is the cleanest but requires IPv4 addresses for every device.
  • Application-layer proxies: A proxy (e.g., HTTP proxy) terminates the IPv6 connection and makes a separate IPv4 connection to the server. This works for specific protocols but not for arbitrary TCP/UDP.
  • 464XLAT: A combination of stateful and stateless translation (RFC 6877) used in mobile networks. It allows IPv4-only apps to run on IPv6-only networks by translating at the device and the network edge.

Frequently Asked Questions

Does NAT64 work with all IPv4 applications?

No. Most client-server applications that use TCP, UDP, or ICMP work, but applications that embed IP addresses in the payload (e.g., FTP active mode) or use IPsec AH (which authenticates the header) will fail unless an ALG or special handling is provided.

What is the difference between NAT64 and NAT-PT?

NAT-PT was an early translation mechanism (RFC 2766) that was deprecated due to complexity and state issues. NAT64 (RFC 6146) is the modern standard, simpler and more robust, with DNS64 as a separate function.

Can I use NAT64 without DNS64?

Yes, but then the IPv6 host must know the synthetic IPv6 address of the IPv4 destination manually. DNS64 automates this, so it is almost always used together.

How many IPv4 addresses do I need for NAT64?

It depends on the number of concurrent connections. Each IPv4 address can handle about 64,000 simultaneous TCP connections (minus reserved ports). For a small office, one address may suffice; for a large ISP, you may need a /24 (256 addresses) or more.

Does translation break end-to-end security?

IPsec AH (Authentication Header) breaks because it authenticates the entire packet, including the IP header, which the engine changes. IPsec ESP (Encapsulating Security Payload) works if the engine does not modify the payload, but NAT64 does change the transport checksum, which can break ESP with checksumming. In practice, IPsec over NAT64 requires special configuration.

Is translation faster than tunneling?

Translation has lower overhead than tunneling because it does not add an extra IP header. However, translation requires stateful processing, which can be slower than simple encapsulation for stateless traffic. In most real-world tests, NAT64 performs comparably to native IPv4 forwarding.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →