1
votes

I am stopping and starting google compute instances, I have 3 GCE instances M1, M2, M3. In initial stage all 3 have unique External IP like

M1 = IP1
M2 = IP2
M3 = IP3

When I stop and start M1 instance it gets new external IP as IP4 But when I stop and start M2 instance it gets old IP of M1 i.e. IP1. Ex. After restarting instances

M1 = IP4
M2 = IP1
M3 = IP2

Essentially on restart of an instances GCE assigning old external IP addresses to instance which are released by other instances.

Is there any way to get unique IP address on each stop/start of instance? I also tried deleting and re-creating instance in new region, How I can ensure that instance will get unique IP address on stop/start or create/delete of an instance?

2

2 Answers

0
votes

You'll have to reserve the external IP, it's called static external IP; otherwise, by default it's ephemeral external IP. You can assign a static external IP when creating instance, or promote it from ephemeral IP to static IP for running instance. Note that you'll be charged for static IPs.

See Configuring an Instance's IP Addresses.

0
votes

similar question was asked about the IP address of the GCE instance and the solution is like below:

You can create a new VM and assign a static IP with the help of Document and below command.

$ gcloud compute instances create [INSTANCE_NAME] --private-network-ip [IP_ADDRESS]

OR

You can change or assign an external IP in your existing VM following the steps of the document (GCLOUD), which are:

  • [Optional] Reserve a static external IP address (if you want to have the reserve external IP and this has cost implications).
  • Delete existing access configs.
  • Add the new external IP address.