Skip to Content

IPv6 in a VPC

What IPv6 is and how its addresses are written, IPv6 in a VPC and dual stack, IPv4 troubleshooting, the egress-only internet gateway and IPv6 routing.

What is IPv6?

  • IPv4 was designed to provide 4.3 billion addresses (they'll be exhausted soon).
  • IPv6 is the successor of IPv4.
  • IPv6 is designed to provide 3.4 × 10³⁸ unique IP addresses.
  • Every IPv6 address in AWS is public and internet-routable (no private range).
  • Format: x.x.x.x.x.x.x.x written as 8 groups separated by colons, where each x is hexadecimal (0000 to ffff).
  • Examples:
    • 2001:db8:3333:4444:5555:6666:7777:8888;
    • 2001:db8:3333:4444:cccc:dddd:eeee:ffff;
    • :: → all 8 segments are zero;
    • 2001:db8:: → the last 6 segments are zero;
    • ::1234:5678 → the first 6 segments are zero;
    • 2001:db8::1234:5678 → the middle 4 segments are zero.

IPv6 in a VPC

  • IPv4 can't be disabled for a VPC and its subnets (it's the default addressing).
  • A VPC can enable IPv6 (public IP addresses) to operate in dual-stack mode.
  • EC2 instances get at least a private internal IPv4 and a public IPv6.
  • They can communicate using either IPv4 or IPv6 to the internet through an internet gateway.

IPv6-only subnets (no IPv4 CIDR) can also be created in a dual-stack VPC, but the VPC itself always keeps IPv4.

IPv4 troubleshooting

  • So, if an EC2 instance can't be launched in a subnet:
    • it's not because it can't get an IPv6 (the space is very large);
    • it's because there are no available IPv4 addresses in the subnet.
  • Solution: add a new IPv4 CIDR to the VPC and create a subnet in it.

Egress-only internet gateway

IPv6 in a VPC: the web server in the public subnet uses the internet gateway, which carries IPv4 and IPv6 in both directions; the server in the private subnet uses an egress-only internet gateway, which lets it start IPv6 connections to the internet but stops the internet from starting connections to it IPv6 in a VPC: the web server in the public subnet uses the internet gateway, which carries IPv4 and IPv6 in both directions; the server in the private subnet uses an egress-only internet gateway, which lets it start IPv6 connections to the internet but stops the internet from starting connections to it

Outbound IPv6 only, like NAT for IPv4.

An egress-only internet gateway:

  • is used for IPv6 only (similar to a NAT gateway, but for IPv6);
  • allows instances in a VPC outbound connections over IPv6, while preventing the internet from initiating an IPv6 connection to the instances;
  • the route tables must be updated.

IPv6 routing

Public subnet route table:

  • 10.0.0.0/16 → local; 2001:db8:1234:1a00::/56 → local;
  • 0.0.0.0/0 → igw-id; ::/0 → igw-id.

Private subnet route table:

  • 10.0.0.0/16 → local; 2001:db8:1234:1a00::/56 → local;
  • 0.0.0.0/0 → nat-gateway-id (IPv4 outbound);
  • ::/0 → eigw-id (IPv6 outbound).

Exam tips

  • "Can't launch instances, subnet has IPv6" → the subnet ran out of IPv4 addresses; add an IPv4 CIDR.
  • "Private instances need outbound-only IPv6" → egress-only internet gateway.
  • "Outbound-only IPv4" → NAT gateway.

Common traps

  • "Disable IPv4 in the VPC to use only IPv6." IPv4 can't be disabled for the VPC.
  • "Use a NAT gateway for IPv6 outbound." Use an egress-only internet gateway.

Check yourself

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt