3

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:

#!/bin/bash

EIP=52.212.151.17
INSTANCE_ID=i-0bdd8a68eb573fd1a

/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?

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47

1 Answers1

3

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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • 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. – Thiago Souza Mar 03 '18 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. – Thiago Souza Mar 03 '18 at 17:30
  • I had to first unassign the ip from the other network interface (aws ec2 unassign-ipv6-addresses). But it worked. – Thiago Souza Mar 03 '18 at 17:48