When I try and associate a second Elastic IP to a small EC2 instance, the currently assigned Elastic IP is disassociated.
Do I need to use a VPC?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Classic EC2 instances can only have a single Elastic IP address associated with them. To get multiple IP addresses, you must use VPC and setup multiple network interfaces on your instance.
NOTE: sometime between 2012 and 2014 AWS changed so that a single ENI can have multiple EIPs assigned to it. This answer, and the question, are no longer relevant as a result.
To get 2 elastic ip's associated to one ec2 instance you need to provide a different route for the second ip. This involves to set a new ip rule which specifies what route should be used.
For example, there is an instance with two network interfaces (lets named
eth1), each one having one internal ip (
188.8.131.52) which translate to his associated elastic ip's.
You need to specify for the ip of eth1(184.108.40.206) to take a different route:
ip rule add from 220.127.116.11 table default
Then, associate his default route to that rule:
ip route add default via 18.104.22.168 dev eth1 table default
And flush the cache:
ip route flush cache
You can dig for a "formal" explanation from this article
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?