CodexBloom - Programming Q&A Platform

GCP Compute Engine VM Network Interface Configuration Not Retaining After Restart

πŸ‘€ Views: 79 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-26
gcp compute-engine networking bash

I'm upgrading from an older version and I'm a bit lost with I'm working with an scenario with a Google Cloud Compute Engine VM where the network interface configuration is not persisting after a restart. I have set up a custom static internal IP address and configured the DNS settings in the Cloud Console, but after rebooting the instance, it defaults back to the ephemeral IP. Here’s the setup I used in gcloud CLI to create the instance: ```bash gcloud compute instances create my-instance \ --zone=us-central1-a \ --machine-type=e2-medium \ --subnet=default \ --address=10.128.0.5 \ --tags=http-server \ --metadata=startup-script='#! /bin/bash apt-get update && apt-get install -y apache2 systemctl start apache2' ``` In the Google Cloud Console, under the VPC network settings, I confirmed that the static IP is reserved and associated with the VM. However, after the VM restarts, I see the IP is reverted to a dynamic one. I've tried checking the network interface settings using: ```bash gcloud compute instances describe my-instance --zone=us-central1-a ``` It still shows the ephemeral IP. I've also looked through the firewall rules and ensured that the necessary ports are open. Is there a step I might be missing in configuring the network interface to retain the static IP across reboots? Any insights or solutions would be greatly appreciated! This is happening in both development and production on Ubuntu 22.04. Any ideas how to fix this? Is this even possible? Is this even possible?