Instance Addressing
All Amazon EC2 instances are assigned two IP addresses at launch: a private address (RFC 1918), and a public address. The public IP address is directly mapped to the private address through Network Address Translation (NAT). Private addresses are only reachable from within the Amazon EC2 network. Public addresses are reachable from the Internet.
Amazon EC2 also provides an internal DNS name and a public DNS name which map to the private and public IP addresses respectively. The internal DNS name can only be resolved within Amazon EC2. The public DNS name resolves to the public IP address outside the Amazon EC2 network and the private IP address within the Amazon EC2 network.
For more information, see Instance Addressing.
Note | |
---|---|
During earlier stages of the Amazon EC2 Beta program, instances used direct addressing. This addressing scheme used the same address for internal and external access. This approach is being deprecated; the documentation does not discuss this addressing scheme. |
All Amazon EC2 instances are allocated a private address by DHCP. These addresses are from a range defined in "RFC 1918 - Address Allocation for Private Internets", are only routable within Amazon EC2, and are used for communication between instances.
This private address is associated exclusively with the instance for its lifetime and is only returned to Amazon EC2 when the instance terminates.
Always use the internal address when you are communicating between Amazon EC2 instances. This ensures that your network traffic follows the highest bandwidth, lowest cost, and lowest latency path through our network.
To determine your IP address
-
Connect to the instance.
-
Enter one of the following:
-
PROMPT>
-
PROMPT>
The second option refers to the instance data (see Instance Metadata).
-
Each instance is provided an internal DNS name in the form
domU-12-31-35-00-35-F3.compute-1.internal
.
It will resolve to the private IP address of the instance from within Amazon EC2;
it will not resolve outside of Amazon EC2.
At launch, a public address is also associated with each Amazon EC2 instance using Network Address Translation (NAT). For more information about NAT, see "RFC 1631: The IP Network Address Translator (NAT)".
This public address is associated exclusively with the instance for its lifetime and is only returned to Amazon EC2 when the instance terminates.
You must use this public address to access your instance outside of Amazon EC2 and you should distribute this address to clients (or through a DNS name that maps to it).
Important | |
---|---|
Amazon EC2 instances cannot access other instances through their public NAT IP address; the private address of the instance in the new NAT environment must be used. |
From your instance, you can determine your public IP address by referring to the instance data. For example:
PROMPT>
curl http://169.254.169.254/latest/meta-data/public-ipv4
Each instance is provided an external DNS name in the form
ec2-72-44-45-204.compute-1.amazonaws.com
.
This DNS name resolves to the public IP address of the instance outside
the Amazon EC2 network and the private IP address from within Amazon EC2 network.
Important | |
---|---|
Amazon EC2 instances cannot access instances in the new NAT environment using their public NAT IP address; they must use the private addresses of the instances in the new NAT environment. |