Hands-On Guide to Setting Up a Google Cloud Platform VM Instance with a Static IP Address

Hands-On Guide to Setting Up a Google Cloud Platform VM Instance with a Static IP Address

Clock Icon2023.06.06 01:27


Hi, if you are new to Google Cloud Platform(GCP) or want to explore it from basics, then this is the perfect blog for you. In this blog post, we will walk through the process of creating a virtual machine (VM) instance on Google Cloud Platform (GCP) and assigning it a static IP address. A static IP address ensures that your VM instance always has the same address, making it easier to connect to and manage. Let's dive into the step-by-step process of setting up your GCP VM instance with a static IP address.

Few things to know about Static IP address-

1. Static IP can be switched to another VM instance in the same project.

2. Static IP remains attached even if you stop the instance. You have to manually detach it.

3. You are billed for Static IP even when you are not using it.

Let's get Started-

Step 1: Create a GCP Project

Before you can create a VM instance, you need to have a GCP project. If you haven't already, create a project by navigating to the GCP Console and clicking on the project drop-down menu at the top of the page. Select "New Project" and follow the prompts to set it up.

Step 2: Enable Compute Engine API

To use the Compute Engine service, you need to enable the Compute Engine API for your project. Go to the GCP Console, select your project, and navigate to the "APIs & Services" > "Library" page. Search for "Compute Engine API" and click on it. On the API details page, click the "Enable" button.

Step 3: Create a VM Instance

Now, let's create a VM instance on GCP. Go to the GCP Console and select your project. In the left sidebar, click on "Compute Engine" > "VM instances." Click the "Create" button to create a new VM instance.

3.1. Choose a Name and Region:

Give your VM instance a descriptive name and select the region where you want your VM to be located. Consider factors like latency and data residency when choosing the region.

3.2. Configure Machine Type and Boot Disk:

Choose the desired machine type and configure the boot disk. You can select a predefined machine type or customize it based on your requirements. Select the operating system and specify the boot disk size.

3.3. Configure Networking:

Expand the Networking, disks, security, management, sole tenancy section. Expand the Networking section. In the Network interfaces section, expand a network interface to edit it.

3.4. Set Up a Static IP Address:

In the "Network interfaces" section, click on "Create IP address" to set up a static IP address. Provide a name for the IP address and select "Create a new static external IP address" option. Click the "Reserve" button to reserve the IP address.

3.5. Configure Firewall Rules:

Specify any firewall rules that you need for your VM instance. By default, GCP allows SSH traffic, but you can add additional rules to allow specific ports or protocols.

3.6. Additional Settings:

You can customize other settings like metadata, labels, and scheduling options based on your requirements. Adjust these settings as needed or leave them at their default values.

Step 4: Review and Create the VM Instance

Review the configuration details on the "Create an instance" page to ensure everything is set up correctly. Once you're satisfied with the settings, click the "Create" button to create the VM instance.

Step 5: Connect to the VM Instance

After the VM instance is created, you can connect to it using SSH or other remote access methods. In the "VM instances" page, locate your newly created VM instance and click the SSH button next to it to open a web-based SSH session. Alternatively, you can use an SSH client like PuTTY or the gcloud command-line tool.

Step 6: Test the Static IP Address

To verify that the static IP address is assigned correctly, log in to your VM instance and use the command-line tools to check the IP address configuration. For example, you can use the ifconfig command on Linux-based systems or ipconfig on Windows-based systems.

By following this hands-on guide, you have successfully created a VM instance on GCP and assigned it a static IP address. This will ensure that your VM instance always has a consistent and easily accessible address. With your VM instance up and running, you can now start deploying your applications and services on Google Cloud Platform.

Thank you!

Happy Learning :)


facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.