JA
header image

枝折 - bookmark

AWS IPv6 Support, DNS64, and NAT64

TCP/IP

CREATED: 2024 / 03 / 10 Sun

UPDATED: 2024 / 03 / 10 Sun

AWS IPv6 Support, DNS64, and NAT64

IPv6 Support for AWS Resources

Last month I worked on removing IPv4 addresses from EC2 instances in AWS and replacing them with IPv6.

That said, some developers’ home environments don’t support IPv6, so some bastion servers and the like still retain IPv4.

For the basic setup, the official documentation covers most of what you need:

Roughly, the flow is:

1. Assign IPv6 to the VPC.
2. Assign an IPv6 address block to subnets associated with the VPC.
3. For public subnets, add a route table entry for ::/0 via the Internet Gateway (IGW).
4. For private subnets, add a route table entry for ::/0 via the Egress-only Internet Gateway.
5. Allow IPv6 traffic in security group inbound/outbound rules.
6. Assign an IPv6 address to the instance.

An Egress-only IGW is required when accessing IPv6 environments. For accessing IPv4 environments, public subnets use DNS64 and private subnets use NAT64. These are discussed below.

For IPv6 support alone, the documentation above should be enough.

DNS64 and NAT64

When working on IPv6 support, DNS64 and NAT64 were concepts I hadn’t encountered before (NAT64/DNS64 is one approach for IPv4 over IPv6 connectivity).

I took the opportunity to research IPv6 a bit, so here’s my understanding of these concepts.

NAT64 converts IPv6 addresses to IPv4 addresses so that servers in an IPv6 environment can send requests to servers in an IPv4 environment. Requests originating in an IPv6 environment are in IPv6 format, so they can’t be sent directly to IPv4. NAT64 converts them to IPv4 and bridges the communication between the two environments.

As noted on JPNIC’s explanation page, requests from IPv6 environments are first sent to a synthesized IPv6 address — a “pseudo-IPv6 address” formed by combining a well-known prefix with an IPv4 address.

In NAT64/DNS64 communication, the IPv4-IPv6 translation address defined in RFC 6052 is used between NAT64 and the devices using it. The well-known prefix for this translation address is 64:ff9b::/96, and the IPv4 address is appended to the end of the IPv4-IPv6 translation address.

NAT64 recognizes this as a request to an IPv4 environment, extracts the IPv4 address portion, and relays the request to that destination.

So how should this IPv4-IPv6 translation address be generated? A server in an IPv6 environment queries DNS to get the destination IP address. But if the destination only supports IPv4 — meaning only an A record is returned — who converts it to an IPv6-formatted address?

That’s where DNS64 comes in. DNS64 acts as a relay for DNS queries from IPv6 environments. When a DNS query returns only an A record, DNS64 generates an IPv4-IPv6 translation address by combining the above well-known prefix with the IPv4 address, and returns it to the server in the IPv6 environment. For example, an IPv4-IPv6 translation address for IPv4 address 192.0.2.33 would be 64:ff9b::192.0.2.33 (just concatenated here — in practice, the IPv4 portion must also follow IPv6 notation).

In summary, DNS64 and NAT64 together enable smooth communication between IPv6 and IPv4 environments (from the IPv6 side).

Understanding these concepts makes AWS configuration easier to reason about:

Note that IPv4-only environments cannot communicate with IPv6-only environments, so services may need to keep IPv4 endpoints available. Depending on the situation, it may not be possible to fully eliminate all IPv4 usage in AWS.

Appendix

NAT64/DNS64 was apparently first commercially deployed on fixed-line connections in the world by BIGLOBE.