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.

gefragt vor einem Jahr2322 Aufrufe
2 Antworten
0
Akzeptierte Antwort

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

profile pictureAWS
beantwortet vor einem Jahr
profile pictureAWS
EXPERTE
überprüft vor einem Jahr
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.

EXPERTE
beantwortet vor einem Jahr
  • 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.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen