-2

We had 2 VPC's in our AWS EC2 network and we had 2 different running servers with the same Elastic IP.

How can this be possible? I thought IP's had to be unique.

ujjain
  • 3,963
  • 15
  • 50
  • 88
  • 1
    It's [a kind of magic](https://www.youtube.com/watch?v=0p_1QSUsbsM) ... – user9517 Apr 06 '16 at 11:08
  • 1
    These are not Elastic IPs. They're public addresses assigned on instance creation, which are different than EIPs. – EEAA Apr 06 '16 at 12:18

1 Answers1

1

This is not an answer about elastic IPs in particular, but a description of how two machines can have the same external IP address. First of all, this is the case in a typical home lan or office, or even a whole company, via NAT.

I have several VPS servers in the same machine (not in AWS) that share the same external IP. This is done using NAT. The machines also have an internal private ip, that is used to communicate between them. On incoming connections, I use iptables to forward certain ports to specific vpss. So, for example, if I want to ssh to vps1, I ssh to port 7001, which is forwarded to the private ip of VPS1 at port 22. For vps2 I use port 7002, and so on. For web connections, I have port 80 forwarded to a VPS that runs a reverse HTTP proxy that routes each request to the appropriate VPS, depending on the hostname specified in the HTTP request, using the private ip (e.g. 192.168.1.101). I use shorewall as a front end to iptables to set this up.

So, perhaps two AWS servers can share the same elastic IP, with some further rule about which server an incoming connection goes to. It may be that the two machines run identical web servers, for load balancing or fault tolerance, so it does not matter which one is used. Each request may go to a different server.

user13097
  • 221
  • 2
  • 7