| Did this page help you? Yes No Tell us about it... |
Topics
This section describes the types of IP addresses available to Amazon EC2 instances, including Elastic IP addresses, which you can remap on demand.
All Amazon EC2 instances are assigned two IP addresses at launch: a private address (RFC 1918) and a public address that are directly mapped to each other 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 that 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.
![]() | Note |
|---|---|
If you require persistent Internet routable IP addresses that can be assigned to and removed from instances as necessary, use Elastic IP addresses. For more information, see Elastic IP Addresses Concepts. |
All Amazon EC2 instances are allocated a private address by DHCP. These ranges are defined in RFC 1918, are only routable within Amazon EC2, and are used for communication between instances. For more information, go to RFC 1918.
This private address is associated exclusively with the instance for its lifetime and is only returned to Amazon EC2 when the instance is stopped or terminated.
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.
Each instance is provided an internal DNS name that resolves 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, go to RFC 1631: The IP Network Address Translator (NAT).
This public address is associated exclusively with the instance until it is stopped, terminated or replaced with an Elastic IP address.
![]() | Important |
|---|---|
Amazon EC2 instances that access other instances through their public NAT IP address are charged for Regional or Internet data transfer, depending on whether the instances are in the same Region. |
Each instance is provided an external DNS name that resolves to the public IP address of the instance outside the Amazon EC2 network and the private IP address from within Amazon EC2 network.
If you're using Amazon Virtual Private Cloud, when you create a subnet in your VPC, you specify the range of private IP addresses in your network to use for the subnet. Each time you launch an instance in the subnet, you can optionally specify an IP address for the instance in the subnet's range. If you don't specify an address, we automatically assign an IP address from the subnet's range. The assigned address stays with the instance until it terminates. Even if you stop and start the instance, it retains the same IP address.
For more information about Amazon VPC, go to the Amazon Virtual Private Cloud Getting Started Guide.
This section describes how to determine the internal and external IP addresses of an instance you own.
To determine your instance's public and private IP addresses
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Instances in the Navigation pane.
The console displays a list of running instances.
Locate and select an instance.
The console displays information about the instance in the lower pane.
To determine the public IP address, use the IP address specified within the Public DNS field.
To determine the private IP address, look at the Private IP Address field.
To determine your instance's public and private IP addresses
Use the ec2-describe-instances command with the instance ID. The instance must be running.
PROMPT>ec2-describe-instancesinstance_idRESERVATION r-f25e6f9a 111122223333 default INSTANCE <instance_id> ami-b232d0db ec2-204-236-202-134.compute-1.amazonaws.com domU-12-31-39-00-86-35.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T08:43:48+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled 204.236.202.134 10.254.137.191 ebs BLOCKDEVICE /dev/sda1 vol-cf13b3a6 2010-03-30T08:01:44.000Z
In the preceding example, the public IP address is 204.236.202.134. The private IP address is 10.254.137.191.
To determine your instance's public and private IP addresses
Construct the following Query request.
https://ec2.amazonaws.com/
?Action=DescribeInstances
&InstanceId.1=instance-id
&...auth parameters...Following is an example response.
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-05-01/">
<reservationSet>
<item>
<reservationId>r-44a5402d</reservationId>
<ownerId>999988887777</ownerId>
<groupSet>
<item>
<groupId>default</groupId>
</item>
</groupSet>
<instancesSet>
<item>
<instanceId>i-28a64341</instanceId>
<imageId>ami-6ea54007</imageId>
<instanceState>
<code>16</code>
<name>running</name>
</instanceState>
<privateDnsName>ip-10-203-46-149.ec2.internal</privateDnsName>
<dnsName>ec2-75-101-217-237.compute-1.amazonaws.com</dnsName>
...
<privateIpAddress>10.203.46.149</privateIpAddress>
<ipAddress>75.101.217.237</ipAddress>
...
</item>
</instancesSet>
</item>
</reservationSet>
</DescribeInstancesResponse>To determine the public IP address, use the IP address specified within
ipAddress.
To determine the private IP address, use the IP address specified within
privateIpAddress.
To determine your private IP address in Linux/UNIX
Connect to the instance.
Enter one of the following commands:
#
ifconfig eth0
#
curl http://169.254.169.254/latest/meta-data/local-ipv4
The second option refers to the instance metadata. For more information, see Using Instance Metadata.
To determine your private IP address in Windows
Connect to the instance.
On the taskbar, click Start, right-click My Computer, and select Properties.
Click the Computer Name tab. The IP address appears in the Full computer name field.
To determine your public IP address
Connect to the instance.
Determine your public IP address from your instance by referring to the instance data.
PROMPT>
GET http://169.254.169.254/latest/meta-data/public-ipv4
Related Topics
Topics
Elastic IP addresses are static IP addresses designed for dynamic cloud computing. An elastic IP address is associated with your account, not a particular instance. You control addresses associated with your account until you choose to explicitly release them.
![]() | Important |
|---|---|
If you're using Amazon Virtual Private Cloud: There's a separate pool of Elastic IP addresses to use with Amazon VPC. Your EC2 Elastic IP addresses won't work with instances in a VPC, and your VPC Elastic IP addresses won't work with instances in EC2.. The following sections describe how to work with EC2 addresses, which have different characteristics than VPC Elastic IP addresses. For information about using VPC Elastic IP addresses, go to Elastic IP Addresses in the Amazon Virtual Private Cloud User Guide. |
By default, all Amazon EC2 instances are assigned two IP addresses at launch: a private (RFC 1918) address and a public address that is mapped to the private IP address through Network Address Translation (NAT).
If you use dynamic DNS to map an existing DNS name to a new instance's public IP address, it might take up to 24 hours for the IP address to propagate through the Internet. As a result, new instances might not receive traffic while terminated instances continue to receive requests.
To solve this problem, Amazon EC2 provides Elastic IP addresses. Elastic IP addresses are static IP addresses designed for dynamic cloud computing. Elastic IP addresses are associated with your account, not specific instances. Any Elastic IP addresses that you associate with your account remain associated with your account until you explicitly release them. Unlike traditional static IP addresses, however, Elastic IP addresses allow you to mask instance or Availability Zone failures by rapidly remapping your public IP addresses to any instance in your account.
You can associate one Elastic IP address with only one instance at a time.
When you associate an Elastic IP address with an instance, its current public IP address is released to the Amazon EC2 public IP address pool. If you disassociate an Elastic IP address from the instance, the instance is automatically assigned a new public IP address within a few minutes. In addition, stopping the instance also disassociates the Elastic IP address from it.
To ensure our customers are efficiently using Elastic IP addresses, we impose a small hourly charge when these IP addresses are not mapped to an instance. When these IP addresses are mapped to an instance, they are free of charge.
For an example of using Elastic IP addresses, see Example.
The following table summarizes the available Elastic IP address command line interface (CLI) tools commands and corresponding API actions. For more information about the CLI commands, go to the Amazon Elastic Compute Cloud Command Line Reference. For more information about the API actions, go to the Amazon Elastic Compute Cloud API Reference.
| CLI Command and API Action | Description |
|---|---|
|
|
Acquires an Elastic IP address for use with your account. |
|
|
Associates an Elastic IP address with an instance. |
|
|
Lists Elastic IP addresses assigned to your account. |
|
|
Disassociates an Elastic IP address from the instance it's associated with. |
|
|
Releases an Elastic IP address associated with your account. After releasing an Elastic IP address, it is released to the IP address pool and might no longer be available to your account. |
This section describes how to assign an Amazon EC2 Elastic IP address to your account.
To allocate a new IP address for use with your account
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Elastic IPs in the Navigation pane.
The console displays a list of Elastic IP addresses assigned to your account.
Click Allocate New Address.
A confirmation dialog box appears.
Ensure the value for EIP used in is set to EC2, and click
Yes, Allocate.
A new standard (EC2) Elastic IP address appears in the list.
![]() | Note |
|---|---|
The Elastic IP address is associated with your account and billed accordingly until you release it. |
To allocate a new IP address for use with your account
Enter the following command:
PROMPT>ec2-allocate-address
Amazon EC2 returns an Elastic IP address similar to the following:
ADDRESS 192.0.2.1 standard
The value standard means this address is for use only with standard (EC2) instances,
and not Amazon VPC instances.
![]() | Note |
|---|---|
The Elastic IP address is associated with your account and billed accordingly until you release the
address with |
To allocate a new IP address for use with your account
Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=AllocateAddress &...auth parameters...
Following is an example response.
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2012-05-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <publicIp>192.0.2.1</publicIp> <domain>standard</domain> </AllocateAddressResponse>
The domain value standard means this address is for use only with standard (EC2)
instances, and not Amazon VPC instances.
![]() | Note |
|---|---|
The Elastic IP address is associated with your account and billed accordingly until you release the
address with |
This section describes how to view the Elastic IP addresses allocated to your account.
To view Elastic IP addresses assigned to your account
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Elastic IPs in the Navigation pane.
The console displays a list of Elastic IP addresses assigned to your account.
To reduce the size of the list, start typing part of the IP address or instance ID to which it is assigned in the search box.
To view Elastic IP addresses assigned to your account
To view all Elastic IP addresses assigned to your account:
PROMPT>ec2-describe-addresses
Amazon EC2 returns a list of Elastic IP addresses similar to the following:
ADDRESS 192.0.2.1 standard ADDRESS 198.51.100.1 standard
If the IP address is mapped, it is followed by the instance ID it's mapped to.
ADDRESS 203.0.113.1 i-996fc0f2 standard
To verify a specific Elastic IP address:
PROMPT>ec2-describe-addressesip_address
Amazon EC2 returns the specified Elastic IP address, similar to the following:
ADDRESS 192.0.2.1 standard
To view Elastic IP addresses assigned to your account
Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=DescribeAddresses &...auth parameters...
Following is an example response.
<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2012-05-01/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<addressesSet>
<item>
<publicIp>192.0.2.1</publicIp>
<domain>standard</domain>
<instanceId/>
</item>
</addressesSet>
</DescribeAddressesResponse>After you allocate an Elastic IP address, you can map it to a running instance.
To associate an Elastic IP address with an instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Instances in the Navigation pane.
The console displays a list of instances.
Write down the instance ID to associate with the Elastic IP address.
Click Elastic IPs in the Navigation pane.
The console displays a list of Elastic IP addresses assigned to your account.
Select an address and click Associate Address.
The Associate Address dialog box appears.
Select the instance from the Instance list box and click Yes, Associate.
The Elastic IP address is associated with the instance.
To associate an Elastic IP address with an instance
Describe running instances:
PROMPT>ec2-describe-instances
Amazon EC2 returns output similar to the following:
RESERVATION r-ae33c2c7 111122223333 default INSTANCE i-afb130c4 ami-3c47a355 ec2-184-73-1-155.compute-1.amazonaws.com domU-12-31-39-09-1D-E5.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T07:42:51+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 184.73.1.155 10.210.34.19 instance-store paravirtual xen RESERVATION r-8a3374e2 111122223333 default INSTANCE i-85b435ee ami-b232d0db ec2-204-236-202-134.compute-1.amazonaws.com domU-12-31-39-00-86-35.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T08:43:48+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled 204.236.202.134 10.254.137.191 ebs paravirtual xen
Write down the instance ID to associate with an Elastic IP address.
Describe Elastic IP addresses assigned to the account:
PROMPT>ec2-describe-addresses
Amazon EC2 returns a list of Elastic IP addresses similar to the following:
ADDRESS 75.101.157.145 standard ADDRESS 198.51.100.1 standard
Write down the Elastic IP address to associate with an instance.
To associate the instance and Elastic IP address:
PROMPT>ec2-associate-address -iinstance_idip_address
Amazon EC2 returns output similar to the following:
ADDRESS 75.101.157.145 i-afb130c4
Associations take a few minutes to complete. To verify the association using
ec2-describe-addresses:
PROMPT>ec2-describe-addresses
Amazon EC2 returns output similar to the following:
ADDRESS 75.101.157.145 i-afb130c4 standard
To verify the association using ec2-describe-instances:
PROMPT>ec2-describe-instancesinstance_id
Amazon EC2 returns output similar to the following:
RESERVATION r-9284a1fa 111122223333 default INSTANCE i-afb130c4 ami-3c47a355 ec2-75-101-157-145.compute-1.amazonaws.com domU-12-31-39-09-25-62.compute-1.internal running 5fmorgin-ami 0 m1.small 2010-03-17T13:17:41+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 75.101.157.145 10.210.42.144 instance-store paravirtual xen
To associate an Elastic IP address with an instance
Describe running instances and write down the instance ID of the instance that you will associate with the Elastic IP address. For more information, see API.
Describe Elastic IP addresses assigned to the account and write down the Elastic IP address that you will associate with the instance. For more information, see API.
Associate the instance and Elastic IP address using the following Query request.
https://ec2.amazonaws.com/ ?Action=AssociateAddress &InstanceId=instance-id&PublicIp=elastic-ip-address&...auth parameters...
Following is an example response.
<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2012-05-01/"> <requestId>ce410ee1-068c-4026-a36e-86cefd453c28</requestId> <return>true</return> </AssociateAddressResponse>
Associations take a few minutes to complete. You can verify the association using
DescribeAddresses or DescribeInstances.
Once an Elastic IP Address is allocated, you can map it to a different running instance.
![]() | Note |
|---|---|
It is highly unlikely that an instance will be configured with its original public IP address that it used prior to being mapped. |
To remap an IP address
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Instances in the Navigation pane.
The console displays a list of running instances.
Write down the new instance ID to associate with the Elastic IP address.
Click Elastic IPs in the Navigation pane.
The console displays a list of Elastic IP addresses assigned to your account.
Locate the IP address to remap and click Disassociate.
A confirmation dialog box appears.
Click Yes, Disassociate.
The Elastic IP address is disassociated from the instance and you are returned to the list of Elastic IP addresses assigned to your account.
Locate the IP address in the list and click Associate.
The Associate Address dialog box appears.
Select the new instance from the Instance ID list box and click Associate.
The Elastic IP address is associated with the new instance.
To remap an IP address
Describe running instances:
PROMPT>ec2-describe-instances
Amazon EC2 returns output similar to the following:
RESERVATION r-9284a1fa 111122223333 default INSTANCE i-b2e019da ami-3c47a355 ec2-75-101-157-145.compute-1.amazonaws.com domU-12-31-39-09-25-62.compute-1.internal running gsg-keypair 0 m1.small 2010-03-17T13:17:41+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 75.101.157.145 10.210.42.144 instance-store paravirtual xen RESERVATION r-f25e6f9a 111122223333 default INSTANCE i-b2e019db ami-3c47a355 ec2-184-73-1-155.compute-1.amazonaws.com domU-12-31-39-09-1D-E5.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T07:42:51+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 184.73.1.155 10.210.34.19 instance-store paravirtual xen
Write down the instance ID to associate with an Elastic IP address.
Associate the address with a new instance:
PROMPT>ec2-associate-address -iinstance_idip_address
Amazon EC2 returns output similar to the following:
ADDRESS 75.101.157.145 i-b2e019db standard
Verify the changes:
PROMPT>ec2-describe-instances
Amazon EC2 returns output similar to the following:
RESERVATION r-9284a1fa 111122223333 default INSTANCE i-b2e019da ami-3c47a355 ec2-184-73-1-123.compute-1.amazonaws.com domU-12-31-39-09-25-62.compute-1.internal running gsg-keypair 0 m1.small 2010-03-17T13:17:41+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 184.73.1.123 10.210.42.144 instance-store paravirtual xen RESERVATION r-f25e6f9a 111122223333 default INSTANCE i-b2e019db ami-3c47a355 ec2-75-101-157-145.compute-1.amazonaws.com domU-12-31-39-09-1D-E5.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T07:42:51+0000 us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled 75.101.157.145 10.210.34.19 instance-store paravirtual xen
To remap an IP address
Describe running instances and write down the instance ID of the instance that you will associate with the Elastic IP address.
Describe Elastic IP addresses assigned to the account and write down the Elastic IP address to remap.
Associate the instance and Elastic IP address using the following Query request.
https://ec2.amazonaws.com/ ?Action=AssociateAddress &InstanceId=instance-id&PublicIp=elastic-ip-address&...auth parameters...
Following is an example response.
<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2012-05-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </AssociateAddressResponse>
Associations take a few minutes to complete.
Verify the association using DescribeAddresses or
DescribeInstances.
The following diagram and table shows an example of using Elastic IP addresses.

![]() |
Web servers are connected to the Internet through Elastic IP addresses (1.1.1.1 and 1.1.1.2) and to database servers through their private IP addresses. |
![]() |
The administrator decides to replace a web server with a larger instance type. To do this, the administrator starts a new instance using a larger instance type, disassociates the 1.1.1.2 Elastic IP address from its running instance, and associates the address with the new instance. |
![]() |
The administrator terminates the old instance. |
The following table describes how you set up the preceding tasks using the AWS Management Console.
Launch Process
|
1 |
Click Instances in the Navigation pane. The console displays a list of running instances. |
|
2 |
Click Launch Instance, select Classic Wizard specify settings that meet the new requirements, and click Launch. |
|
3 |
Click Elastic IPs in the Navigation pane. The console displays a list of Elastic IP addresses assigned to the account. |
|
4 |
Select the desired IP address that is assigned to another instance, click Disassociate, and confirm the disassociation. You're returned to the list of Elastic IP addresses. |
|
5 |
Locate the IP address in the list, click Associate, select the new instance, and confirm the association. The Elastic IP address is assigned to the new instance. |
|
6 |
Click Instances in the Navigation pane, select the old instance, and clicks Terminate. Amazon EC2 begins shutting down the old instance. |
The following example shows how to set up the preceding tasks using the command line tools (assuming the Elastic IP address is 67.202.55.255).
![]() | Note |
|---|---|
The command to disassociate the address is optional because
|
PROMPT>ec2-run-instances ami-6ba54002 -n 1 --availability-zone us-east-1aRESERVATION r-a034c7c9 924417782495 default INSTANCE i-3ea74257 ami-6ba54002 pending 0 m1.large 2007-07-11T16:40:44+0000 us-east-1aPROMPT>ec2-disassociate-address 67.202.55.255ADDRESS 67.202.55.255PROMPT>ec2-associate-address -i i-3ea74257 67.202.55.255ADDRESS 67.202.55.255 i-43a4412aPROMPT>ec2-terminate-instances i-4bc32334INSTANCE i-4bc32334 running shutting-down
The following demonstrates how to set up these tasks using the API.
Run a new larger instance type using RunInstances.
Disassociate the Elastic IP address from the old instance using
DisassociateAddress.
![]() | Note |
|---|---|
This step is optional because |
Associate the Elastic IP address with the new instance using
AssociateAddress.
Verify the association using DescribeInstances.
Terminate the old instance using TerminateInstances.
By default, all accounts are limited to 5 Elastic IP addresses because public (IPV4) Internet addresses are a scarce public resource. We strongly encourage you to use Elastic IPs primarily for load balancing use cases, and private IP addresses for all other inter-node communication.
If you feel your architecture warrants an exception, please complete the Amazon EC2 Elastic IP Address Request Form. We will ask you to think through your use case and help us understand your need for additional addresses.
If you intend to send email to third parties from Amazon EC2 instances, we suggest you provision one or more elastic IP addresses and provide them to us in the Request to Remove Email Sending Limitations form. AWS works with ISPs and Internet anti-spam organizations (such as Spamhaus) to reduce the chance that your email sent from these addresses will be flagged as spam.
In addition, assigning a static reverse DNS record to your Elastic IP address used to send email can help avoid having email flagged as spam by some anti-spam organizations. You can provide us with a reverse DNS record (for example: foo.yourcompany.com) to associate with your addresses through the aforementioned form. Note that a corresponding forward DNS record (A Record) pointing to your Elastic IP address must exist before we can create your reverse DNS record.