- Amazon EC2 Cookbook
- Sekhar Reddy Aurobindo Sarkar
- 329字
- 2021-07-30 10:14:16
Allocating Elastic IP addresses
Elastic IP (EIP) address is the static public IP address. You can attach and detach the EIP from EC2 instance at any time. Instances in EC2-Classic support only one private IP address and corresponding EIP. Instances in EC2-VPC support multiple private IP addresses, and each one can have a corresponding EIP. If you stop the instance in EC2-Classic the EIP is disassociated from instance, and you have to associate it again when you start the instance. But if you stop the instance in EC2-VPC, the EIP remains associated with the EC2 instance.
In this recipe, we list the commands for allocating an Elastic IP address in a VPC and associating it with the network interface.
How to do it…
For allocating EIP addresses, perform the following steps:
- Run the following command to allocate the EIP:
$ aws ec2 allocate-address --domain [Domain]
You have to specify whether domain is standard or VPC. Record the allocation ID for further use.
Domain value indicates whether the EIP address is used with instances in EC2-Classic (standard) or instances in a EC2-VPC (VPC).
- Next, run the following command to create the EIP in VPC:
$ aws ec2 allocate-address --domain vpc
- Then, run the following command to associate the EIP to the Elastic Network Interface (ENI):
$ aws ec2 associate-address --network-interface-id [NetworkInterfaceId] --allocation-id [AllocationId]
You need to provide the network interface ID of the ENI and allocation ID of the EIP you obtained in step 1. If you don't specify the private IP address, then the Elastic IP address is associated with the primary IP address.
The parameters used in this command are described here:
[NetworkInterfaceId]
: This gives the ENI ID to attach[AllocationId]
: This provides the allocation ID of the EIP for EC2-VPC
- Finally, run the following command to associate the EIP to ENI:
$ aws ec2 associate-address --network-interface-id eni-d68df2b3 --allocation-id eipalloc-82e0ffe0
See also
- The Creating an instance with multiple NIC cards and a static private IP address recipe
- Learning Microsoft Azure
- 2016年度注冊會計師全國統一考試專用輔導教材(圖解版):審計
- 從零開始學房地產會計
- 成功通過PMP(第3版)
- Business Intelligence Cookbook:A Project Lifecycle Approach Using Oracle Technology
- 公司內部審計
- Oracle Primavera Contract Management,Business Intelligence Publisher Edition v14
- 內審人員進階之道:內部審計操作實務與案例解析
- 計量經濟學理論與應用:基于Eviews的應用分析
- QlikView for Developers Cookbook
- 財務會計習題集
- Getting Started with Citrix? Provisioning Services 7.0
- 人口預測模型研究及應用
- Windows Server 2016 Administration Fundamentals
- 合規型內部審計:精準發現違規行為,實時化解合規風險