amazon-web-servicesamazon-ec2flexlm

EC2 running software on private IP intead of public IP


I've set up an EC2 instance where I need to run some software, flexlm, and be accessible through a public IP address. I've set up an elastic IP and things should be working.

However, whenever I ssh into the instance or connect to it through the AWS console, I have the private IP in the terminal as my userID (e.g.)

ec2-user@ip-<private-ip>$

When I run the software, which is a license checking software, it says I am running the software from the private IP and not the EIP I set up.

Maybe I am understanding private vs public IP wrong? When I ssh into my EC2 is it even possible to run things and have them be exposed through the public IP? When someone accesses the EIP is that just being routed to the private IP?

Some clarity on the difference between IPs would be useful as well as info on if I can run software and have it run from the private IP.

Update: Added more detail


Solution

  • Amazon EC2 instances do not actually know their Public IP address. All traffic arrives at their Private IP address.

    When the instance access the Internet, traffic flows through the Internet Gateway. At this time, the Internet Gateway performs a 'reverse NAT' and makes the traffic 'appear' to come from the Elastic IP address (or, if there is no EIP, then the random Public IP address assigned to the instance). Similarly, when traffic from the Internet is sent to the EIP, the Internet Gateway forwards it to the Private IP address of the instance.

    The instance itself, however, has no record of the Elastic IP address. The benefit of this is that the EIP can be instantly remapped to another Amazon EC2 instance (useful when doing failover) without changing any configuration on the instance itself.

    If your software product accesses the Internet to determine its Public IP address (eg going to https://icanhazip.com/), then it will see its correct Public IP address. However, if it looks on the instance, it will not find the Public IP address.