I have two AWS instances working in high availability. (I'm using keepalived)

I have an Elastic IP associated, everything was a fine.

I used this script so to change the instance IP in case o failover:



/usr/bin/aws ec2 disassociate-address --public-ip $EIP
/usr/bin/aws ec2 associate-address --public-ip $EIP --instance-id  $INSTANCE_ID

But now my server has an ipv4 and ipv6. And i cannot do the same for ipv6. Only ipv4.

How can i do the same for ipv6? Since there is no Elastic ipv6?

1 Answer 1


IPv6 addressing is different than IPv4 is usually managed. IPv6 is managed by subnet, not by individual address as in IPv4 today.

So in Amazon AWS, you need to first assign an IPv6 CIDR block to your VPC. Then you can assign individual IPv6 addresses to your instances. See Amazon's guides for getting started with IPv6 and understanding IP addressing.

By default your instances will obtain IPv6 addresses automatically. If you don't want this, you can assign a specific IPv6 address to it. But unlike IPv4, with IPv6 you assign addresses to the network interface of the instance, not to the instance.

Use aws ec2 assign-ipv6-addresses to assign IPv6 addresses to your instances' network interfaces.

  • I'm trying to test your solution. By when i run the command, i get: aws: error: argument operation: Invalid choice, valid choices are... and the option assign-ipv6-addresses is not available. Although it's written in the documentation. Mar 3, 2018 at 17:16
  • Nevermind, the ubuntu 16.04 repository is outdated. I updated with pip install awscli --upgrade --user, and the command is available now. Mar 3, 2018 at 17:30
  • I had to first unassign the ip from the other network interface (aws ec2 unassign-ipv6-addresses). But it worked. Mar 3, 2018 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.