DEV Community

Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on

Fix your external IP address for your VM using GCP

Why are we doing?
Actually every time you stop your VM, you lose your external IP address and a new is generated. Thus we are solving this issue.

You can make some changes to fix your external IP addresses. For that, go to you VPC and then you may see something like this

Image description
Note: Once you create a VM, a VPC is created for you.

So now we will reserve a static IP address to fix it.

Image description

Now give it a name and choose if you want to use the premium or standard network.

Image description

Note: Choose the same region your VM has already been launched.Otherwise it will not work for your VM.

Also you can choose the IP version and type . The type should be Region here as we are focusing to solve VM issue which is launched in a region.

Then press reserve.

So, this is what we created:

Image description

Now to attach it with our VM to use it, press this Change button:

Image description

Image description
Now choose your VM from the list

Note: You can not find your VM if this VPC and Vm is not in the same region.

Image description

So, after attaching it, the earlier VPC which was created by default is gone (For which your external IP IP .

Image description

Now this becomes your external IP address and won't change in case the VM is stopped.

Image description

Image description
Here we stopped the VM but you can still find your External IP address.

Problem Solved!

Tips: Once you are finished working with your VM, once you delete it, don't forget to delete the Static IP address you just created in your VPC.

Because it charges still when you are not using it.

Top comments (0)