Private Static IP for EC2

0

How can I set static IP for already running EC2. Does the auto assigned private IP gets changed under any scenario?

질문됨 2년 전5326회 조회
2개 답변
1

Private IP of a running or stopped instance would not change. You will loose it once the instance is terminated.

If you want to retain a private IP for an EC2 instance even after termination, you could do this -

  1. Create a custom ENI (network interface) with a custom IPV4 address within the CIDR range of the subnet (e.g. us-east-1a) you want to launch the EC2 instance.
  2. Launch the ec2 instance in the same subnet (e.g. us-east-1a)
  3. Attach the custom ENI to your new EC2 instance (From Instances page of AWS Console - Actions --> Networking --> Attach Network Interface) You would see 2 private ips for the instance after this.

Please keep in mind this will lock your EC2 instance to a specific Availability Zone. Also, make sure you understand the implications of doing this after considering the alternate options.

An alternate to this is to use an Elastic IP, which is a fixed public ip address that you can attach to any of your instances.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html

profile pictureAWS
답변함 2년 전
0
수락된 답변

The private IP address of an Amazon EC2 instance will never change while an instance is running or stopped. However, EC2 instances can have multiple IP addresses. (For more: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/MultipleIP.html). Pls, remember, that there is no way to remove the Primary IP address from any EC2 instances. Furthermore, two EC2 instances cannot have the same IP. only one IP can be assigned to one only one EC2 instance. (This is only for the private IP address, not the public IP address).

Apart from that, for public IP use Elastic IP address. For more: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

VISI
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠