How NAT64 Translates IPv6 to IPv4: Stateful vs Stateless, Packet by Packet

This walkthrough uses captures from the late Nick Russo's free packet-capture library, preserved by the Internet Archive. They are in the NAT archive, nat_pcap.zip, under nat_pcap/: nat64_pat_udp.pcapng, nat64_pat_icmp.pcapng, and nat64_stateless_udp.pcapng, with nat64_pool_udp.pcapng, nat64_pool_icmp.pcapng, nat44_pat_udp.pcapng, and nat44_pat_icmp.pcapng for comparison. The rest of the library is listed on his job aid page. We decoded the captures with VisualEther, which turns a Wireshark PCAP into a sequence diagram with a plain-English caption on every message.

An IPv6-only host can't talk to an IPv4-only server directly: the two protocols have different headers and different address sizes, and neither side understands the other's packets. NAT64 (Network Address Translation from IPv6 to IPv4) is a router function that bridges the gap. The host sends an ordinary IPv6 packet to an IPv6 address that stands for the IPv4 server. The NAT64 router rebuilds that packet with an IPv4 header, sends it to the server, and translates the reply back to IPv6.

Most explanations of NAT64 stop at a diagram. These captures show the same packet on both sides of the translator, so you can see exactly which fields the router rewrites and which it leaves alone. The lab has two IPv6-only clients, one NAT64 router, and one IPv4 server, 198.51.100.2. This article follows the lab through three captures:

  1. Stateful NAT64 with PAT, UDP. Both clients share one IPv4 address, and the router rewrites a port to tell them apart.
  2. Stateful NAT64 with PAT, ping. ICMPv6 Echo becomes ICMP Echo, and the echo identifier plays the role of the port.
  3. Stateless NAT64, UDP. Each client's IPv6 address has an IPv4 address built in, so the router needs no table at all.

Each capture is drawn as an annotated sequence diagram. Each participant gets a lane, each message is an arrow numbered as in Wireshark, and each carries a caption saying what it does. Every diagram comes as an interactive viewer, an HTML page, and a printable PDF. In the viewer and the HTML page, clicking any message opens its full Wireshark field tree.

๐Ÿ’ก Read the walkthrough and a diagram side by side: open the interactive diagram in a split-screen window, or open the HTML version in a new tab and snap the two windows side by side. Each section below links its own diagram.

What is NAT64?

NAT64 is a translator that lets IPv6-only hosts reach IPv4-only servers by converting each packet between IPv6 and IPv4 headers. It sits at the edge of an IPv6-only network, on the path to the IPv4 Internet. The payload, such as a UDP datagram or a ping, passes through unchanged apart from its checksum.

Several related terms appear throughout:

RFC 6144 describes the overall framework.

What is 64:ff9b::/96?

64:ff9b::/96 is the NAT64 Well-Known Prefix: an IPv6 prefix reserved for representing IPv4 addresses inside IPv6 (RFC 6052 section 2.1). With a /96 prefix, the IPv4 address fills the last 32 bits (section 2.2). The clients in the stateful captures reach 198.51.100.2 by sending to 64:ff9b::c633:6402:

PartBitsValue
Well-Known Prefix0โ€“9564:ff9b::
IPv4 address, in hex96โ€“127c633:6402 = c6.33.64.02 = 198.51.100.2

The client needs no NAT64 support. It sends to 64:ff9b::c633:6402 like any IPv6 address, and the network routes 64:ff9b::/96 to the NAT64 router. RFC 6052 calls an address like this, which stands for an IPv4 host, an IPv4-converted address.

An operator can also use a network-specific prefix from their own address space, as the stateless capture does with fc00:6464::/96. Two rules decide the choice:

How were the captures made?

Each capture holds both sides of the translator. The pcapng file header shows that Wireshark merged it from two captures, 1.pcapng and 2.pcapng, taken on the same Windows host. The MAC addresses show the two sides: the clients' IPv6 frames run from aa:bb:cc:00:01:20 to the router's aa:bb:cc:00:03:20, and the IPv4 frames from the router's aa:bb:cc:00:03:30 to the server's aa:bb:cc:00:02:30. The aa:bb:cc addresses are typical of Cisco IOS images running in an emulator.

Both source captures used one host clock, so the frame order across the translator is real. The gaps between a packet and its translation on the other side, 36 to 348 ยตs in the three main captures, are an emulated router's timing on a merged file. Treat them as "well under a millisecond", not as a translation benchmark.

Both "clients" send from the same MAC address, so they are two addresses on one lab device. To the translator they are separate IPv6 hosts, which is what matters here.

Why does the diagram show a NAT64 router lane?

The translator owns no address that appears in these packets. On the IPv6 side, the clients address their packets to the server's synthesized address, 64:ff9b::c633:6402. On the IPv4 side, the packets come from the NAT address, 203.0.113.44. Drawn literally, the IPv6 arrows would end at a "server" lane, and the IPv4 arrows would start from a separate "NAT" lane.

The diagrams instead map both addresses to one NAT64 router lane between the clients and the server, because that is where the packets physically go: every IPv6 frame is addressed to the router's MAC, and every IPv4 frame leaves from it. The captions and the address fields beside each arrow keep the real addresses in view.

Capture 1: stateful NAT64 with PAT (UDP)

Capture 1 has eight frames over 2.6 seconds. Each client sends one 16-byte UDP datagram from port 4001 to the server's port 5001, and the server echoes it back. The router translates every packet both ways and puts both clients behind one IPv4 address, 203.0.113.44.

sequenceDiagram accTitle: Stateful NAT64 with PAT, UDP accDescr: Client 1 sends UDP over IPv6 from port 4001 to 64:ff9b::c633:6402. The NAT64 router forwards it over IPv4 from 203.0.113.44 port 4001 to 198.51.100.2. The reply comes back the same way. Client 2 then sends from port 4001 too, and the router sends it from 203.0.113.44 port 1024. The reply to port 1024 is translated back to Client 2 port 4001. participant C1 as Client 1 participant C2 as Client 2 participant N as NAT64 router participant S as IPv4 server C1->>N: [1] UDP over IPv6, port 4001 to 64:ff9b::c633:6402 N->>S: [2] UDP over IPv4, 203.0.113.44 port 4001 S->>N: [3] Reply to 203.0.113.44 port 4001 N->>C1: [4] Reply over IPv6 to port 4001 C2->>N: [5] UDP over IPv6, port 4001 again N->>S: [6] UDP over IPv4, 203.0.113.44 port 1024 S->>N: [7] Reply to 203.0.113.44 port 1024 N->>C2: [8] Reply over IPv6 to port 4001
Capture 1 at a glance. Both clients send from port 4001; the second leaves as port 1024. Frame numbers are in brackets.

How does NAT64 translate an IPv6 packet to IPv4?

The router replaces the 40-byte IPv6 header with a 20-byte IPv4 header, takes the IPv4 destination from the last 32 bits of the IPv6 destination, and substitutes one of its own IPv4 addresses for the source. The UDP ports and data pass through; the UDP checksum is recomputed. Frames 1 and 2 are the same datagram before and after:

FieldFrame 1 (IPv6, from Client 1)Frame 2 (IPv4, to the server)Why
Source address2001:db8:1:4::1203.0.113.44Stateful mapping, stored in the router's table
Destination address64:ff9b::c633:6402198.51.100.2Last 32 bits of the IPv6 address (RFC 6052)
Source port40014001Free, so the router kept it
Hop limit / TTL6463The translator is a router: one decrement (RFC 7915 section 5.1)
Header size40 bytes20 bytesPayload length 24 becomes total length 44
Identificationnone in IPv60The translator's choice; see below
Don't Fragment (DF)none in IPv6setThe translator's choice; see below
Traffic class / TOS00Copied
UDP checksum0x7dcc0x6f5eIts pseudo-header includes the IP addresses

Expand the IPv6 header and the UDP header in frame 1. Wireshark recognizes the Well-Known Prefix and shows the embedded IPv4 address:

๐Ÿ“ฆ [00001] Frame 1 UDP over IPv6 2020-09-12T12:12:59.691785Z ๐Ÿ–ฅ Client 1 → ๐Ÿ”„ NAT64 router
frame : Frame 1: Packet, 78 bytes on wire (624 bits), 78 bytes captured (624 bits) on interface -, id 0
Section number : 1
Interface id : 0 (-)
Interface name : -
Encapsulation type : Ethernet (1)
Arrival Time : Sep 12, 2020 17:42:59.691785000 India Standard Time
UTC Arrival Time : Sep 12, 2020 12:12:59.691785000 UTC
Epoch Arrival Time : 1599912779.691785000
Time shift for this packet : 0.000000000 seconds
Time since reference or first frame : 0.000000000 seconds
Frame Number : 1
Frame Length : 78 bytes (624 bits)
Capture Length : 78 bytes (624 bits)
Frame is marked : False
Frame is ignored : False
Protocols in frame : eth:ethertype:ipv6:udp:data
Character encoding : ASCII (0)
eth : Ethernet II, Src: aa:bb:cc:00:01:20, Dst: aa:bb:cc:00:03:20
Destination : aa:bb:cc:00:03:20
Destination (resolved) : aa:bb:cc:00:03:20
Destination OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : aa:bb:cc:00:03:20
Address (resolved) : aa:bb:cc:00:03:20
Address OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Source : aa:bb:cc:00:01:20
Source (resolved) : aa:bb:cc:00:01:20
Source OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : aa:bb:cc:00:01:20
Address (resolved) : aa:bb:cc:00:01:20
Address OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Type : IPv6 (0x86dd)
Stream index : 0
ipv6 : Internet Protocol Version 6, Src: 2001:db8:1:4::1, Dst: 64:ff9b::c633:6402
0110 .... = Version : 6
0110 .... = Version : 6 [This field makes the filter match on "ip.version == 6" possible]
.... 0000 0000 .... .... .... .... .... = Traffic Class : 0x00 (DSCP: CS0, ECN: Not-ECT)
.... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint : Default (0)
.... .... ..00 .... .... .... .... .... = Explicit Congestion Notification : Not ECN-Capable Transport (0)
.... 0000 0000 0000 0000 0000 = Flow Label : 0x00000
Payload Length : 24
Next Header : UDP (17)
Hop Limit : 64
Source Address : 2001:db8:1:4::1
Address Space : Global Unicast
Special-Purpose Allocation : Documentation
Source : False
Destination : False
Forwardable : False
Globally Reachable : False
Reserved-by-Protocol : False
Source or Destination Address : 2001:db8:1:4::1
Address Space : Global Unicast
Special-Purpose Allocation : Documentation
Source : False
Destination : False
Forwardable : False
Globally Reachable : False
Reserved-by-Protocol : False
Source Host : 2001:db8:1:4::1
Source or Destination Host : 2001:db8:1:4::1
Destination Address : 64:ff9b::c633:6402
Address Space : Reserved by IETF
Special-Purpose Allocation : IPv4-IPv6 Translat.
Source : True
Destination : True
Forwardable : True
Globally Reachable : True
Reserved-by-Protocol : False
Source or Destination Address : 64:ff9b::c633:6402
Address Space : Reserved by IETF
Special-Purpose Allocation : IPv4-IPv6 Translat.
Source : True
Destination : True
Forwardable : True
Globally Reachable : True
Reserved-by-Protocol : False
Destination Host : 64:ff9b::c633:6402
Source or Destination Host : 64:ff9b::c633:6402
Embedded IPv4 Prefix : 0064ff9b0000000000000000
Destination Embedded IPv4 : 198.51.100.2
Embedded IPv4 : 198.51.100.2
Stream index : 0
udp : User Datagram Protocol, Src Port: 4001, Dst Port: 5001
Source Port : 4001
Destination Port : 5001
Source or Destination Port : 4001
Source or Destination Port : 5001
Length : 24
Checksum : 0x7dcc [unverified]
Checksum Status : Unverified
Stream index : 0
Stream Packet Number : 1
Timestamps
Time since first frame : 0.000000000 seconds
Time since previous frame : 0.000000000 seconds
UDP payload (16 bytes)
fake-field-wrapper : fake-field-wrapper
data
Data : 00010000abcdabcdabcdabcdabcdabcd
Length : 16
Rendered from a Wireshark PCAP by VisualEther.

Frame 2 shows the same datagram after translation. Compare the addresses, the TTL, the flags, and the checksum:

๐Ÿ“ฆ [00002] Frame 2 UDP over IPv4 2020-09-12T12:12:59.691885Z ๐Ÿ”„ NAT64 router → ๐ŸŒ IPv4 server
frame : Frame 2: Packet, 58 bytes on wire (464 bits), 58 bytes captured (464 bits) on interface -, id 0
Section number : 1
Interface id : 0 (-)
Interface name : -
Encapsulation type : Ethernet (1)
Arrival Time : Sep 12, 2020 17:42:59.691885000 India Standard Time
UTC Arrival Time : Sep 12, 2020 12:12:59.691885000 UTC
Epoch Arrival Time : 1599912779.691885000
Time shift for this packet : 0.000000000 seconds
Time delta from previous captured frame : 100.000 microseconds
Time delta from previous displayed frame : 100.000 microseconds
Time since reference or first frame : 100.000 microseconds
Frame Number : 2
Frame Length : 58 bytes (464 bits)
Capture Length : 58 bytes (464 bits)
Frame is marked : False
Frame is ignored : False
Protocols in frame : eth:ethertype:ip:udp:data
Character encoding : ASCII (0)
eth : Ethernet II, Src: aa:bb:cc:00:03:30, Dst: aa:bb:cc:00:02:30
Destination : aa:bb:cc:00:02:30
Destination (resolved) : aa:bb:cc:00:02:30
Destination OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : aa:bb:cc:00:02:30
Address (resolved) : aa:bb:cc:00:02:30
Address OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Source : aa:bb:cc:00:03:30
Source (resolved) : aa:bb:cc:00:03:30
Source OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : aa:bb:cc:00:03:30
Address (resolved) : aa:bb:cc:00:03:30
Address OUI : aa:bb:cc
.... ..1. .... .... .... .... = LG bit : Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Type : IPv4 (0x0800)
Stream index : 1
ip : Internet Protocol Version 4, Src: 203.0.113.44, Dst: 198.51.100.2
0100 .... = Version : 4
.... 0101 = Header Length : 20 bytes (5)
Differentiated Services Field : 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint : Default (0)
.... ..00 = Explicit Congestion Notification : Not ECN-Capable Transport (0)
Total Length : 44
Identification : 0x0000 (0)
010. .... = Flags : 0x2, Don't fragment
0... .... = Reserved bit : Not set
.1.. .... = Don't fragment : Set
..0. .... = More fragments : Not set
...0 0000 0000 0000 = Fragment Offset : 0
Time to Live : 63
Protocol : UDP (17)
Header Checksum : 0xd55e [validation disabled]
Header checksum status : Unverified
Source Address : 203.0.113.44
Source or Destination Address : 203.0.113.44
Source Host : 203.0.113.44
Source or Destination Host : 203.0.113.44
Destination Address : 198.51.100.2
Source or Destination Address : 198.51.100.2
Destination Host : 198.51.100.2
Source or Destination Host : 198.51.100.2
Stream index : 0
udp : User Datagram Protocol, Src Port: 4001, Dst Port: 5001
Source Port : 4001
Destination Port : 5001
Source or Destination Port : 4001
Source or Destination Port : 5001
Length : 24
Checksum : 0x6f5e [unverified]
Checksum Status : Unverified
Stream index : 1
Stream Packet Number : 1
Timestamps
Time since first frame : 0.000000000 seconds
Time since previous frame : 0.000000000 seconds
UDP payload (16 bytes)
fake-field-wrapper : fake-field-wrapper
data
Data : 00010000abcdabcdabcdabcdabcdabcd
Length : 16
Rendered from a Wireshark PCAP by VisualEther.

The UDP checksum is the only change inside the datagram. UDP computes its checksum over a pseudo-header that includes the source and destination IP addresses, so new addresses mean a new checksum even when no byte of the payload changes. RFC 6146 section 3.7 requires the update.

The reply, frames 3 and 4, runs the other way. The router looks up 203.0.113.44:4001 in its table, finds [2001:db8:1:4::1]:4001, and rebuilds an IPv6 packet from 64:ff9b::c633:6402, the same address the client sent to. The server's TTL 255 becomes hop limit 254, and the flow label is 0, as RFC 7915 section 4.1 requires. The client sees an ordinary IPv6 reply, 530 ยตs after its request.

What state does a stateful NAT64 router keep?

For each mapping, the router remembers an IPv6 address and port, and the IPv4 address and port it chose for them. RFC 6146 section 3.1 calls this table the Binding Information Base (BIB) and keeps one for TCP, one for UDP, and one for ICMP. Section 3.2 adds session tables that also record the remote end. After frame 2, the UDP BIB holds:

IPv6 sideIPv4 side
[2001:db8:1:4::1]:4001203.0.113.44:4001

The table is why only the IPv6 side can start a conversation (RFC 6146 section 1.1). An IPv4 packet that arrives for 203.0.113.44 with no matching entry has nowhere to go, unless an operator has configured a static mapping.

A UDP mapping lasts at least 2 minutes after the last packet, and RFC 6146 recommends a default of at least 5 minutes (section 3.5.1).

Why did port 4001 become 1024?

Because 203.0.113.44:4001 was already taken. Client 2 also sent from port 4001 (frame 5). Two clients can't share one IPv4 address and port, or the router couldn't tell their replies apart. The router gave Client 2 port 1024 instead (frame 6), and the table gained a second entry, [2001:db8:1:4::2]:4001 โ†” 203.0.113.44:1024. The reply to port 1024 (frame 7) goes back to Client 2 at port 4001 (frame 8). Client 2 never learns its port was rewritten.

RFC 6146 section 3.5.1.1 leaves the choice of port to the router, with two recommendations: stay in the same range as the original port (1024โ€“65535 here, which 1024 is), and keep its parity, odd or even. Because 4001 is odd and 1024 is even, this router ignores the parity advice. Keeping the original port when it is free is the router's own behavior, not a requirement.

The NAT44 comparison capture shows the pattern the other way around: there, the first client got 1024, and the second kept 4001. Both captures fit "keep the port if it is free; otherwise take the lowest free port from 1024 up", but two samples can't prove the rule. Perhaps something else was holding 4001 when the NAT44 capture began.

Capture 2: ping through stateful NAT64

Capture 2 uses the same lab and the same PAT address, 203.0.113.44. Each client sends one ping with 52 bytes of data; the capture has eight frames over 1.2 seconds.

sequenceDiagram accTitle: Ping through stateful NAT64 accDescr: Client 1 sends an ICMPv6 Echo Request, type 128, identifier 0x2098. The NAT64 router sends it to the IPv4 server as an ICMP Echo Request, type 8, from 203.0.113.44 with the same identifier. The server's Echo Reply, type 0, is translated into an ICMPv6 Echo Reply, type 129. Client 2 does the same with identifier 0x0391. participant C1 as Client 1 participant C2 as Client 2 participant N as NAT64 router participant S as IPv4 server C1->>N: [1] ICMPv6 Echo Request (128), ID 0x2098 N->>S: [2] ICMP Echo Request (8), ID 0x2098 S->>N: [3] ICMP Echo Reply (0), ID 0x2098 N->>C1: [4] ICMPv6 Echo Reply (129) C2->>N: [5] ICMPv6 Echo Request (128), ID 0x0391 N->>S: [6] ICMP Echo Request (8), ID 0x0391 S->>N: [7] ICMP Echo Reply (0), ID 0x0391 N->>C2: [8] ICMPv6 Echo Reply (129)
Capture 2 at a glance. ICMPv6 types 128 and 129 become ICMP types 8 and 0; the echo identifier tells the clients apart. Frame numbers are in brackets.

How does NAT64 handle ping (ICMP)?

It translates the message, not just the header. ICMPv6 and ICMP use different type numbers for the same messages, so the router changes Echo Request type 128 to type 8 on the way out, and Echo Reply type 0 to type 129 on the way back (RFC 7915 sections 5.2 and 4.2). It also recomputes the checksum, for a reason specific to ICMP:

So the router must take the addresses out of the checksum going to IPv4 and put them back going to IPv6. The checksums in the capture show the arithmetic:

FrameMessageChecksumChange from the request
1ICMPv6 Echo Request (128)0x7a55
2ICMP Echo Request (8)0x4ac1Pseudo-header removed, type changed
3ICMP Echo Reply (0)0x52c1+0x0800: type 8 became 0
4ICMPv6 Echo Reply (129)0x7955โˆ’0x0100 from frame 1: type 128 became 129

Frames 3 and 4 differ from their requests only by the type byte. Swapping source and destination doesn't change the pseudo-header's sum, so the type is the only thing left to move the checksum.

What does NAT64 use instead of a port for ping?

The echo identifier. Ping has no ports, so RFC 6146 section 3.1 keeps a separate ICMP table that maps an (IPv6 address, identifier) pair to an (IPv4 address, identifier) pair. Client 1 pings with identifier 0x2098 and Client 2 with 0x0391. Both leave as 203.0.113.44, and the identifier tells their replies apart.

The two identifiers didn't collide, so the router kept both. RFC 6146 section 3.5.3 lets the router choose any free identifier. Had both clients picked the same one, it would have rewritten one, just as it rewrote port 4001 in capture 1.

ICMP mappings are short-lived: the default lifetime is 60 seconds (RFC 6146 section 3.5.3), against at least 2 minutes for UDP.

The translated pings carry TTL 63, Identification 0, and DF set, like the UDP datagrams in capture 1. The server's echo replies carry Identification 0 and DF set too, but for a different reason: the server built each reply from the request's header. Its UDP replies in capture 1 use a running Identification and DF clear.

Capture 3: stateless NAT64

Capture 3 repeats the UDP exchange of capture 1, eight frames over 3.1 seconds, with the router configured for stateless translation. What changes on the wire is the clients' IPv6 addresses: each now has an IPv4 address built in.

sequenceDiagram accTitle: Stateless NAT64, UDP accDescr: Client 1, fc00:6464::cb00:7101, sends UDP from port 4001 to fc00:6464::c633:6402. The NAT64 router strips the prefix from both addresses and sends it from 203.0.113.1 port 4001 to 198.51.100.2. The reply returns the same way. Client 2, fc00:6464::cb00:7102, also sends from port 4001 and leaves as 203.0.113.2 port 4001. participant C1 as Client 1 participant C2 as Client 2 participant N as NAT64 router participant S as IPv4 server C1->>N: [1] UDP over IPv6 from fc00:6464::cb00:7101 N->>S: [2] UDP over IPv4 from 203.0.113.1 port 4001 S->>N: [3] Reply to 203.0.113.1 N->>C1: [4] Reply over IPv6 C2->>N: [5] UDP over IPv6 from fc00:6464::cb00:7102 N->>S: [6] UDP over IPv4 from 203.0.113.2 port 4001 S->>N: [7] Reply to 203.0.113.2 N->>C2: [8] Reply over IPv6
Capture 3 at a glance. Each client's IPv6 address embeds its IPv4 address, so no port is rewritten. Frame numbers are in brackets.

Both clients' addresses sit under the network-specific prefix fc00:6464::/96, and each ends in an IPv4 address:

IPv6 addressLast 32 bitsIPv4 addressRole
fc00:6464::cb00:7101cb.00.71.01203.0.113.1Client 1
fc00:6464::cb00:7102cb.00.71.02203.0.113.2Client 2
fc00:6464::c633:6402c6.33.64.02198.51.100.2The server, as seen from IPv6

RFC 6052 calls the clients' addresses IPv4-translatable: IPv6 addresses given to IPv6 hosts so that a stateless translator can map them to IPv4. To translate, the router strips the prefix from both addresses. On the way back, it restores the prefix. It never consults a table, and it would give the same answer after a reboot.

Wireshark shows no embedded IPv4 address for these packets: it recognizes only the Well-Known Prefix, not a network-specific one.

The rest of the header translation is identical to capture 1: TTL 63, Identification 0, DF set, new UDP checksum (0xaebe to 0x6f89). The ports are not touched. Client 2 also sends from port 4001, but it leaves as 203.0.113.2:4001, because it doesn't share an address with anyone.

What is the difference between stateful and stateless NAT64?

Stateful NAT64 keeps a table and lets many IPv6 hosts share a few IPv4 addresses. Stateless NAT64 keeps no table, but gives every IPv6 host its own IPv4 address. The header translation (SIIT) is the same in both; only the address mapping differs.

Stateful NAT64Stateless NAT64
SpecificationRFC 6146 (uses SIIT for headers)RFC 7915 (SIIT)
IPv6 host addressesAny IPv6 addressIPv4-translatable: an IPv4 address embedded under the prefix
IPv4 source chosen byA table entry made from the first packetThe last 32 bits of the IPv6 source
Saves IPv4 addressesYes, with PAT: many hosts per addressNo: one IPv4 address per host
Port rewritingYes, when ports collide (capture 1, frame 6)Never (capture 3, frame 6)
Who can start a conversationIPv6 side only, unless static mappings existEither side (RFC 6144 section 3.2.1)
Router restart or failoverLoses the table unless it is synchronized to a standby; open conversations breakNothing lost

Stateless translation suits IPv6-only servers or devices, such as those in an IPv6-only data center, that must be reachable from IPv4, where there are enough IPv4 addresses to give each one its own. Stateful translation suits the common case: many IPv6-only clients reaching the IPv4 Internet through a handful of public addresses.

The captures side by side

The table compares the three published captures with the pool and NAT44 captures from the same archive. Client 1 and Client 2 are separated by a slash.

CaptureIPv6 source โ†’ destinationIPv4 source โ†’ destinationPort or echo ID, before โ†’ afterWhat produced the IPv4 source
Stateful PAT, UDP (capture 1)2001:db8:1:4::1 / ::2 โ†’ 64:ff9b::c633:6402203.0.113.44 / 203.0.113.44 โ†’ 198.51.100.24001 โ†’ 4001 / 4001 โ†’ 1024RFC 6146 UDP table, one shared address
Stateful PAT, ping (capture 2)2001:db8:1:4::1 / ::2 โ†’ 64:ff9b::c633:6402203.0.113.44 / 203.0.113.44 โ†’ 198.51.100.2ID 0x2098 / 0x0391, both keptRFC 6146 ICMP table, identifier as the port
Stateful pool, UDP (nat64_pool_udp)2001:db8:1:4::1 / ::2 โ†’ 64:ff9b::c633:6402203.0.113.2 / 203.0.113.3 โ†’ 198.51.100.24001 kept / 4001 keptRFC 6146 table, one pool address per client
Stateful pool, ping (nat64_pool_icmp)2001:db8:1:4::1 / ::2 โ†’ 64:ff9b::c633:6402203.0.113.3 / 203.0.113.2 โ†’ 198.51.100.2ID 0x08b5 / 0x060c, both keptRFC 6146 table, one pool address per client
Stateless, UDP (capture 3)fc00:6464::cb00:7101 / ::cb00:7102 โ†’ fc00:6464::c633:6402203.0.113.1 / 203.0.113.2 โ†’ 198.51.100.24001 kept / 4001 keptRFC 7915 and RFC 6052: last 32 bits of the IPv6 source
NAT44 PAT, UDP (nat44_pat_udp)(IPv4 inside: 10.1.4.1 / 10.1.4.2)203.0.113.44 / 203.0.113.44 โ†’ 198.51.100.24001 โ†’ 1024 / 4001 โ†’ 4001NAT44 table, one shared address

The pool rows show why pool translation doesn't need its own diagram. On the IPv4 side it looks like stateless translation: each client gets its own IPv4 address and keeps its port. The difference is inside the router, which picks a free pool address and stores the mapping. Nor is the assignment order fixed: Client 1 got 203.0.113.2 in the UDP capture and 203.0.113.3 in the ping capture.

In every NAT64 capture, the destination was produced the same way, by taking the last 32 bits of the IPv6 destination.

Why are translated packets sent with DF set and Identification 0?

Because this router follows RFC 6145, the translation standard that RFC 7915 replaced in 2016. Every IPv4 packet the router built from IPv6 carries Identification 0 and the Don't Fragment (DF) flag set. RFC 6145 section 5.1 specified exactly that for small packets: Identification "All zero", and DF "set to one". (It allowed an exception only for packets between 88 and 1280 bytes, and these are 44 and 80 bytes.)

RFC 7915 section 5.1 reverses both rules. DF must be clear for any translated packet of 1260 bytes or less, and the Identification comes from a generator at the translator. Section 5 makes the DF rule a MUST. A translator following RFC 7915 would send these packets with DF clear and a nonzero Identification.

The reason for the change is fragmentation. With DF set, an IPv4 router whose next link has a smaller MTU must drop the packet and send back an ICMP "Fragmentation Needed" error. If a firewall blocks that error, the packet silently disappears. Clearing DF on small packets lets IPv4 routers fragment them instead, and the generated Identification lets the receiver reassemble the pieces.

In the other direction, the same router behaves like RFC 7915. The server's UDP replies have DF clear, and the translated IPv6 replies carry no Fragment Header: their payload length, 24, is the UDP datagram alone. RFC 6145 section 4 said a translator SHOULD add a Fragment Header whenever DF is clear, while allowing an option to omit it on unfragmented packets. RFC 7915 section 4 adds one only when the packet is already fragmented or too large for IPv6's 1280-byte minimum MTU.

RFC 6146, the stateful NAT64 standard, still points to RFC 6145 for header translation, because it predates RFC 7915. When you compare a router's behavior with the RFCs, check which one its documentation follows.

Why does NAT64 need DNS64?

Because applications look up names, not addresses, and an IPv4-only server has no IPv6 address in DNS. A query for its AAAA record (the IPv6 address record) comes back empty, so an IPv6-only client has nothing to connect to. DNS64 fills the gap. When a name has no AAAA record but has an A record (the IPv4 address record), the DNS64 server builds an AAAA record from it by placing the IPv4 address under the NAT64 prefix (RFC 6147 section 5.1.6). A lookup of a server at 198.51.100.2 returns 64:ff9b::c633:6402, and the client's packets flow to the NAT64 router.

DNS64 synthesizes nothing when a real AAAA record exists (section 5.1.1), so dual-stack servers are reached over native IPv6.

These captures contain no DNS traffic. The clients were told to send to 64:ff9b::c633:6402 and fc00:6464::c633:6402 directly, the job DNS64 does in a real network. To see how DNS resolution itself works, from root servers to the final answer, see DNS Recursive Resolution, Packet by Packet.

DNS64 can't help an application that uses an IPv4 address literal, such as http://198.51.100.2/, or that opens only IPv4 sockets. For those, RFC 6877 describes 464XLAT: a stateless translator on the host or home router (the CLAT) turns the application's IPv4 packets into IPv6, and the provider's stateful NAT64 (the PLAT) turns them back into IPv4. Mobile networks commonly use it to run IPv6-only.

NAT64 vs NAT44

NAT44, the NAT in nearly every home router, translates an IPv4 address to another IPv4 address. NAT64 translates between IPv6 and IPv4. The nat44_pat_udp comparison capture runs the same UDP test through NAT44 with PAT, from the IPv4 clients 10.1.4.1 and 10.1.4.2 to the same server:

sequenceDiagram accTitle: NAT44 with PAT, UDP accDescr: Client 1, 10.1.4.1, sends UDP from port 4001. The NAT44 router sends it from 203.0.113.44 port 1024 to 198.51.100.2 and translates the reply back. Client 2, 10.1.4.2, sends 22.8 seconds later, also from port 4001, and leaves as 203.0.113.44 port 4001. participant C1 as Client 1 (10.1.4.1) participant C2 as Client 2 (10.1.4.2) participant N as NAT44 router participant S as IPv4 server C1->>N: [1] UDP, port 4001, TTL 255 N->>S: [2] UDP from 203.0.113.44 port 1024, TTL 254 S->>N: [3] Reply to port 1024 N->>C1: [4] Reply to 10.1.4.1 port 4001 C2->>N: [5] UDP, port 4001 N->>S: [6] UDP from 203.0.113.44 port 4001 S->>N: [7] Reply to port 4001 N->>C2: [8] Reply to 10.1.4.2 port 4001
The NAT44 PAT comparison (nat44_pat_udp). The second client's datagram follows 22.8 seconds later. Frame numbers are in brackets.

On the IPv4 side, NAT44 and NAT64 produce the same UDP datagrams. NAT44's frame 2 and NAT64's frame 6 both leave 203.0.113.44:1024 for 198.51.100.2:5001 with checksum 0x7aff and identical data. NAT44's frame 6 matches NAT64's frame 2 the same way, with checksum 0x6f5e. The server can't tell which kind of client is behind the address. Only the IPv4 headers differ:

NAT44 PATNAT64 PAT
Inside packetsIPv4IPv6
Destination the client usesThe server's real address, 198.51.100.2A synthesized address, 64:ff9b::c633:6402
What the router rewritesSource address and portThe whole IP header, plus the source port when needed
Outside TTL254 (client sent 255)63 (client sent hop limit 64)
Outside DFClear, as the client sent itSet, the translator's choice
ChecksumsUDP updated for the new address and port; ICMP untouchedUDP updated; ICMP rebuilt for the new type and pseudo-header
Needs DNS helpNoYes, DNS64, unless clients use the prefix directly

The ICMP difference shows in the nat44_pat_icmp capture: its translated pings keep their checksums, because ICMP for IPv4 covers no addresses and the router kept the identifiers. For how NAT44 affects other protocols, such as IPsec, see IPsec ESP Transport vs Tunnel Mode, and NAT Traversal.

Troubleshooting: why can't an IPv6-only host reach an IPv4 server?

First make sure the host has an IPv6 address, a default route, and a DNS server; DHCPv6 vs SLAAC covers where each comes from. Then work along the path the packet takes:

  1. Does the name resolve to a NAT64 address? Query the AAAA record through the client's resolver. No answer means DNS64 is missing or not in use. An answer outside your NAT64 prefix means a real AAAA exists, and the problem is native IPv6, not NAT64.
  2. Is the prefix routed to the translator? The client's network needs a route for 64:ff9b::/96 (or your network-specific prefix) toward the NAT64 router. A capture on the IPv6 side should show the packets reaching the router's MAC, as frame 1 does here.
  3. Is the IPv4 address allowed under that prefix? A conforming translator drops Well-Known Prefix packets for private or special-purpose IPv4 addresses (RFC 6052 section 3.1). Use a network-specific prefix or 64:ff9b:1::/48 for those.
  4. Does the translated packet leave? Capture on the IPv4 side, as these captures do. No packet there means the router didn't translate the IPv6 packet: check the NAT64 configuration, the rule that selects which IPv6 sources to translate, and whether the pool or PAT address is exhausted.
  5. Does the reply come back to the NAT address? The server's reply must route to the PAT or pool address (203.0.113.44 here). If it routes elsewhere, the mapping is never used.
  6. Is the mapping still alive? Long-idle UDP or ping flows lose their entries (at least 2 minutes for UDP, 60 seconds by default for ICMP). A reply after that has nowhere to go.
  7. Do large packets fail while small ones work? Look for ICMP "Fragmentation Needed" or ICMPv6 "Packet Too Big" errors and check DF on the translated packets. A translator that sets DF on everything, as this one does, depends on those errors reaching the sender.

Frequently asked questions

Is NAT64 the same as NAT-PT? No. NAT-PT (RFC 2766) was an earlier IPv6-to-IPv4 translator with its own DNS handling built in. RFC 4966 documented its problems, including that built-in DNS handling, and moved it to historic status; NAT64 with DNS64 replaced it.

Does the IPv6 client need to support NAT64? No. With DNS64, the client sees an ordinary IPv6 address and sends ordinary IPv6 packets. The network does the rest: it routes the prefix to the translator.

Can an IPv4 host start a connection to an IPv6 host through NAT64? With stateful NAT64, only through a static mapping, because a dynamic mapping exists only after the IPv6 side sends first. With stateless NAT64, yes: every IPv6 host has a fixed IPv4 address.

Why is the hop limit 64 but the TTL 63? The translator is a router, so it decrements the hop count once as it forwards the packet (RFC 7915 section 5.1). The same happens on the way back: TTL 255 becomes hop limit 254.

What happens to the IPv6 flow label? It has no IPv4 equivalent, so it is dropped going to IPv4 and set to 0 coming back (RFC 7915 section 4.1).

Does NAT64 work for TCP? Yes. TCP is handled like UDP: a TCP table maps addresses and ports, and the checksum is updated. These captures use UDP and ping only.

What is the difference between 64:ff9b::/96 and 64:ff9b:1::/48? 64:ff9b::/96 is the global Well-Known Prefix, for public IPv4 addresses only. 64:ff9b:1::/48 is reserved for local translation inside one network and can represent private IPv4 addresses (RFC 8215).

Takeaways

  1. NAT64 rebuilds the IP header and leaves the payload alone. Addresses, TTL, flags, lengths, and checksums change. The data crosses unchanged, and so do the ports unless PAT must resolve a collision.
  2. The destination is arithmetic; the source is a choice. The IPv4 destination is always the last 32 bits of the IPv6 destination. The IPv4 source comes from a table in stateful NAT64, and from the host's own address in stateless NAT64.
  3. PAT tells clients apart by port, and ping by echo identifier. Two clients sending from port 4001 left as ports 4001 and 1024.
  4. Checksums change even when the payload doesn't. UDP and ICMPv6 checksums cover the IP addresses; ICMP for IPv4 doesn't, so ping checksums are rebuilt in both directions.
  5. Stateless NAT64 saves no IPv4 addresses. It trades the table for one IPv4 address per IPv6 host and lets either side start.
  6. Check which RFC your translator follows. This router sets DF and Identification 0 on every translated packet, as RFC 6145 said. RFC 7915, the current standard, says to clear DF on packets of 1260 bytes or less.
  7. DNS64 makes NAT64 usable. Without it, applications never learn the synthesized address. Use 464XLAT for applications that need IPv4 itself.