Understanding Internal/External IP Address in Google Cloud VM Instances And Working With Static IP Address

Introduction

In this article, we will deep dive into IP addresses and understand the difference between external and internal IP Adress of VM instances in the Google Cloud Platform. We would also learn how to create a static IP Address and assign it to a VM instance.

Prerequisites

  • Google free tier or paid account.
  • Basic knowledge of using Google cloud services and understanding of Virtual Machines in general.
  • At least one VM instance was created in the Google Cloud platform. 

In this article, we will cover the following topics:

  • Understand external and internal IP Adress of VM instance 
  • Create and assign static IP Adress to VM instance
  • Delete VM instance and release static IP Address

Step 1 - Understand the external and internal IP Adress of the VM instance 

If you are new to Google Compute Engine and VM instances kindly refer to this article - Understanding Google Compute Engine And Set Up First VM In Google Cloud Platform.

Search for VM Instances and it would display the list of all the VM instances created under your project.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Whenever a new VM Instance is created VM instance will have at least one Internal IP address attached to it. An internal IP Address is specific to a Corporate network and is used for Internal communication.Whenever VM Instance is stopped Internal IP Address remains attached to the VM.

VM Instance may or may not have an external IP Address and it depends on how the VM instance has been configured. We have configured the VM instance and installed HTTP Server for external communication.

External IP Address is used for communication with the external world.

This VM instance can be reached by accessing IP Address http://34.125.249.155/ in the browser and we would see the homepage for Apache Server.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Now let us stop this VM Instance by clicking on the stop button. It would ideally take 2-3 minutes to completely stop a VM instance. Once the instance is stopped we would no longer see the External IP Address and we would not able to access the VM instance in the browser using the old External Adress. The internal IP Address still exists.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Now start the VM Instance using the start button. It would take 2-3 minutes and we would see a new External IP Address assigned to this VM instance.VM instance can be reached from the internet using a new external IP Address.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

There would be instances where we would need a static External IP Address and it should not change even when the VM instance is stopped. One option to achieve this is to use a static IP Address in GCP.

Step 2 - Create a Static IP Address

Under VPC Network log into IP Address. Click on Reserve external Static Address.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Configure to create a new static external IP Address.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

As seen External Static IP Address name dev has been assigned to the VM instance developmentserver. It is important that the IP Address and VM instance has to be in the same region.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Now stop the VM instance. Even if VM instance is stopped IP Address is attached to it and when it is started again same External IP Address is retained.

Understanding Internal and External IP Address in Google Cloud VM Instances and working with static IP Address

Points to Remember while working with Static External IP Address

  1. It is billed even when VM is not in use.
  2. It has to be removed explicitly and will not be deleted automatically.
  3. It can be assigned to any VM instance.
  4. The billing cost when it is in use is less than when it is not in use.

Step 3 - Delete VM Instance and Release static IP Address

Under VM instances click on delete and it would delete the VM instance.

Under IP Address click on release IP Address and it would delete the static IP Address.

Summary

In this article, we have learned how to work with internal and external IP Addresses.

In the upcoming articles, we would see in more detail the creation of VM using instance templates.

Thanks a lot for reading. I hope you liked this article. Please share your valuable suggestions and feedback. Write in the comment box in case you have any questions. Have a good day!


Similar Articles