Gili
Gili

Reputation: 90160

How to change an existing server's IP address?

Is it possible to programmatically change an instance's IP address from one ephemeral address to another, ideally without rebooting the instance?

I tried:

gcloud compute instances delete-access-config --zone <zone> --access-config-name="External NAT" <instance-name>
gcloud compute instances add-access-config --zone <zone> --access-config-name="External NAT" <instance-name>

or switching from a ephemeral address to a static IP and back, but it GCE keeps on reusing the same 1-2 IP addresses. I want to avoid reusing the same IP addresses.

Upvotes: 1

Views: 6540

Answers (1)

David
David

Reputation: 9731

You can accomplish this indirectly using static routes, as described at https://cloud.google.com/compute/docs/instances-and-network#staticnetworkaddress.

Upvotes: 4

Related Questions