Retain private IP when restoring EC2 instance from AWS Backup or Snapshot

0

Hello all.

I'm testing restores of an EC2 instance and I've found that it never retains the same private IP, regardless of whether it's restored from AWS Backup or an EC2 snapshot.

I've even tried deleting the original instance prior to doing the restore in hopes that the restored EC2 would have the same the private IP as the original (because I know you can't reconfigure the primary private IP of an EC2 or have the same IP on another NIC), but no luck.

It would seem this is a pretty basic functionality and concept, as some servers have hardcoded IPs that can't be changed without wrecking production environments. Am I missing something or is there just absolutely no ability to keep the same private IP when doing a restore?

Please advise.

질문됨 일 년 전2322회 조회
2개 답변
0
수락된 답변

You can specify the IP Address in a Launch Template, specifically AWS::EC2::Launch Template NetworkInterface

profile pictureAWS
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
0

It's good to avoid the issue using domain names or internal load balancers, but there are some ways of getting the same private IP.

One is to use an additional ENI that you attach to your instance in addition to the default ENI. Other resources can reference the private IP of this additional ENI, which can be detached and attached to another instance as needed. Note it needs to be in the same AZ but different subnet than the default ENI.

Another hack I've heard of is using a very small subnet (/28) and using up all but one of the available IP addresses. Then when your instance starts it's forced to always use the same IP address.

전문가
답변함 일 년 전
  • Thanks for adding the much better answer @Rodney Lester. My info was way out of date - somehow in the shift from Launch Configurations to Launch Templates years ago I never noticed (or have forgotten) that specifying a primary IPv4 address is now possible. Cheers.

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

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

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

관련 콘텐츠