11

I am trying to make a kind of proxy using elastic IPs on my Amazon EC2 instance. My question is, say I associate an elastic IP to my Amazon instance, and then I make an outbound connection from my EC2 instance to a server, say www.yahoo.com.

What IP address will www.yahoo.com see, the original Amazon EC2 server IP or the elastic IP I have associated to it?

Sorry if this is a basic question, but this is all new to me.

J.Zil
  • 1,123
  • 3
  • 21
  • 29

1 Answers1

27

If an elastic IP is associated with an EC2 instance, that's the instance's external IP.

You can demonstrate this by doing curl canhazip.com in the command line.

ceejayoz
  • 32,910
  • 7
  • 82
  • 106
  • Does this apply to VPC's? My outgoing IP does not appear to be the same as the Elastic IP applied to the main interface. – John McKim Sep 17 '14 at 07:51
  • @JohnMcKim Yes, it applies to VPCs. The only caveat is sometimes you'll have your VPC subnet going through a NAT instance rather than directly. – ceejayoz Sep 17 '14 at 12:47
  • If you are going through a NAT instance, does that subvert the EIP outbound? – flickerfly Jun 22 '17 at 21:17
  • 2
    @flickerfly Yes, you'd be showing up as the NAT instance's EIP. – ceejayoz Jun 23 '17 at 01:03
  • @flickerfly If you want an instance (within a VPC) to use its assigned EIP, you'll want to put it into a subnet of its own that has 0.0.0.0/0 (or whatever is needed toward internet) route going through an internet gateway if your instances are otherwise configured to use either AWS-provided NAT, or an EC2-based NAT of your own. – Ville Feb 08 '18 at 21:04