Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
Am I able to keep the current Elastic IP that I currently have assigned to my EC2 instance when using a new VPC? –  Ian Warburton Nov 8 '12 at 17:13
1  
Classic Elastic IP addresses cannot be assigned to a VPC instance. –  Matt Houser Nov 9 '12 at 2:42
add comment

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 eth0 and eth1), each one having one internal ip (172.31.4.255 and 172.48.55.23) which translate to his associated elastic ip's.

You need to specify for the ip of eth1(172.48.55.23) to take a different route:

 ip rule add from 172.48.55.23 table default

Then, associate his default route to that rule:

 ip route add default via 172.48.0.1 dev eth1 table default

And flush the cache:

ip route flush cache

You can dig for a "formal" explanation from this article

share|improve this answer
    
Thank you! Running Plesk on an EC2 and needed a second IP address - simple yea? ha! I've been at it for hours and these 3 commands finally solved my routing issues. –  dtbaker Jun 14 at 11:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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