Manage the IPv6 addresses for your EC2 instances - Amazon Elastic Compute Cloud

Manage the IPv6 addresses for your EC2 instances

You can view the IPv6 addresses assigned to your instance, assign a public IPv6 address to your instance, or unassign an IPv6 address from your instance. You can view these addresses in the console through either the Instances page or the Network Interfaces page.

Assign an IPv6 address to an instance

If your VPC and subnet have IPv6 CIDR blocks associated with them, you can assign an IPv6 address to your instance during or after launch. The IPv6 address is assigned from the IPv6 address range of the subnet, and is assigned to the network interface with the device index of eth0.

To assign an IPv6 address during instance launch

Follow the procedure to launch an instance, and when you configure Network Settings, choose the option to Auto-assign IPv6 IP.

To assign an IPv6 address after launch
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Instances.

  3. Select your instance, and choose Actions, Networking, Manage IP addresses.

  4. Expand the network interface. Under IPv6 addresses, choose Assign new IP address. Enter an IPv6 address from the range of the subnet or leave the field blank to let Amazon choose an IPv6 address for you.

  5. Choose Save.

To assign an IPv6 address using the command line

You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.

View the IPv6 addresses

You can use the Amazon EC2 console, AWS CLI, and instance metadata to view the IPv6 addresses for your instances.

To view the IPv6 addresses for an instance using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Instances.

  3. Select the instance.

  4. On the Networking tab, locate IPv6 addresses.

To view the IPv6 addresses for an instance using the command line

You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.

To view the IPv6 addresses for an instance using instance metadata
  1. Connect to your instance. For more information, see Connect to your EC2 instance.

  2. Get the MAC address of the instance from http://169.254.169.254/latest/meta-data/network/interfaces/macs/.

  3. Use the following command to view the IPv6 address.

    IMDSv2
    [ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \ && curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/network/interfaces/macs/mac-address/ipv6s
    IMDSv1
    [ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/mac-address/ipv6s
    Tools for Windows PowerShell
    PS C:\> Invoke-RestMethod http://169.254.169.254/latest/meta-data/network/interfaces/macs/mac-address/ipv6s

Unassign an IPv6 address from an instance

You can unassign an IPv6 address from an instance at any time.

To unassign an IPv6 address from an instance using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Instances.

  3. Select your instance, and choose Actions, Networking, Manage IP addresses.

  4. Expand the network interface. Under IPv6 addresses, choose Unassign next to the IPv6 address.

  5. Choose Save.

To unassign an IPv6 address from an instance using the command line

You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.