I am currently trying to use the instance scheduler to stop and start my compute instances once a day to refresh their public ip's. Through much testing I have noticed that if I stop the instance for any period of time 5min -1hour they will return with the same IP even though they are all set to ephemeral IP. I have tried this with the scheduler and just stopping and starting the instance through the GCP Compute console.
I normally use Terraform to create my network and the scheduler and the IP never changes. When I manually create an instance it will change 1 out of every 3 stop and starts.
I have changed from e2-small instances to n2-standard-2 instances and tried setting the on-host- management to Terminate and I still have the same IP's.
I am using the Premium network but have also tried Standard with no change.
Is there any setting or any way to ensure that you are getting a true ephemeral IP like AWS and Azure give you when I stop and start my instances? Any help would be greatly appreciated.
Hi @brian_077 ,
External IP addresses assigned to instances are generally ephemeral by default, which means they should be released when the instance is stopped, and a new IP address should be assigned when the instance is started again.
If you are experiencing an issue where the same external IP address is obtained even after stopping the instance for an extended period, it could be due to a few reasons:
1. The external IP address might be reserved, meaning it's purposely kept the same even when you stop and start the instance.
2. Your instance is connected to any load balancer or network setup that reserves or assigns specific IP addresses.
You can try these steps to obtain a new external IP address for your instance:
1. Release the external IP address
Before you stop the instance, go to the GCP Console, find your VM instance, go to the "External IP addresses" section, and release the assigned IP address. This will disconnect the IP address from the instance.
2. Reconfigure Instance NIC
Change the instance's network settings to remove the external IP address before you stop the instance.
3. Stop the instance
Once you release or remove the IP address, stop the instance, wait for a bit, and then start it again. Doing this will make it more likely for your instance to get a new external IP address.
You may also want to check this related community discussion about ephemeral IP address. It explains the nature and behaviour of ephemeral IP address in GCP.