-1

I have created an ec2 ubuntu instance with an initial public IP assigned. After, I added two additional elastic IPs to the machine and did ip addr add ELASTIC_IP/20 dev ens5 to enable them on the machine.

There is an existing program written in NodeJS that constantly sends out rest requests. Just want to confirm my understanding, if localAddress is not specified in the request, then all traffic will still be sent through the initial public IP. am i correct? would be appreciate if anyone can share pointers to this.

Thank you!

2 Answers2

1

if localAddress is not specified in the request, then all traffic will still be sent through the initial public IP. am i correct?

No. When you associate an Elastic IP with an instance, the original public address is released from the instance and is no longer associated with it.

Your instance will use the Elastic IP for outgoing requests.

From the docs:

When you associate an Elastic IP address with an instance or its primary network interface, the instance's public IPv4 address (if it had one) is released back into Amazon's pool of public IPv4 addresses.

gshpychka
  • 8,523
  • 1
  • 11
  • 31
  • there could be multiple elastic IP assigned to the same instance. the original IP i mean for the first elastic IP i assigned to the machine. – user2913464 Apr 01 '22 at 15:47
0

Answer to my own question:

The order is determined by IP table on the machine.

Regarding how to add multiple IPs to the same machine, there are 2 ways to do this:

  1. multiple IPs attach to the same network interface. Then enable send requests through different local Addresses.

Or

  1. multiple network interfaces each with its own IP.