Cloud Computing, Google Cloud (GCP)

4 Mins Read

A Guide to Connect two different VPCs through VPNs in Google Cloud Platform

Voiced by Amazon Polly

Introduction to VPCs

VPC (Virtual Private Cloud) in Google Cloud is a virtual network environment that allows you to create and manage resources, such as virtual machines, containers, and load balancers, in a logically isolated and secure environment.

VPCs allow you to define your network topology, including IP address ranges, subnets, and route tables. You can also configure security groups and network access control lists (ACLs) to control inbound and outbound traffic to and from your resources.

With VPCs, you can create multiple subnets in different availability zones within a region. This allows you to distribute resources across multiple data centers for high availability and fault tolerance.

VPCs provide a powerful tool for network segmentation and isolation. You can use VPCs to create separate environments for development, testing, and production or to isolate different applications and services from each other for security or compliance reasons.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

What are VPNs?

VPN (Virtual Private Network) is a technology that allows you to establish a secure and encrypted connection between two or more devices over the internet. VPNs are commonly used to provide remote access to private networks, encrypt internet traffic, and bypass internet censorship and content restrictions.

When you use a VPN, your device connects to a VPN server through an encrypted tunnel. All the data you send and receive over the internet is encrypted and transmitted through this tunnel, making it difficult for anyone else to intercept or eavesdrop on your internet traffic.

Architecture Diagram

ad

We are performing this blog using two different projects, GCP-project-1 and GCP-project-2, and created two VPCs, vpc-mumbai, and vpc-us-central, created VPN gateways, and established a tunnel. Below you can see some screenshots with the explanation.

Step-by-Step Guide

Steps 1: Create one virtual machine in vpc-mumbai

step1

Create one virtual machine in vpc-us-central.

step1b

Step 2: Create an External Static IP address. It will require creating a gateway.

step2

step2b

Step 3: Create a VPN between VPC networks.

step3

For demonstration, I am going for Classic VPN. If you need High-availability, use High-availability (HA) VPN.

step3b

Step 4: Creating a gateway for the Mumbai region.

step4

Creating a gateway for the us-central region.

step4b

Step 5: Important – Remote peer IP address is-Static-External IP address of US-Central

step5

The Routing option should be Route-based, and the IP range should be VPC-US-Central IP address range then create.

step5b

Here, you can see the first handshake is made from the Mumbai region to the us-central region.

Repeat the above steps for the us-central region.

step5c

step5d

After creating the gateway, you can see that it works when we ping another VPC’s IP and the connection is Established.

step5e

step5f

Benefits of using VPN

  • Security: VPNs provide high security by encrypting your internet traffic, making it difficult for anyone to intercept or eavesdrop on your data.
  • Privacy: VPNs can protect your online privacy by hiding your IP address and location, preventing websites and apps from tracking your online activities.
  • Access to restricted content: VPNs can bypass geo-restrictions and access websites and online services that may be blocked or restricted in your country or region.
  • Remote access: VPNs can provide remote access to a private network, allowing employees to work from home or on the go while maintaining the network’s security.

Overall, VPNs are a powerful tool for protecting your online privacy and security and accessing content and services that may be restricted in your location.

Conclusion

To summarize, connecting two different VPCs through VPNs in the Google Cloud Platform involves creating a VPN gateway in each VPC, creating a VPN tunnel between the gateways, configuring the VPN tunnel settings, and testing the connection between the VPCs. This process allows you to securely connect two VPCs and enable resources within them to communicate over an encrypted connection. This can be useful in scenarios where you have multiple VPCs across different regions or availability zones and need to connect them to facilitate data transfer, application integration, or disaster recovery. 

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding GCP, VPC and VPN and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. Can we perform this using a single GCP-Project?

ANS: – Yes, if you’re not using a free tier account. If you’re using a free-tier account, it will give a quota error.

2. What are the other ways to connect VPCs?

ANS: – The other ways are:

  1. VPC Peering
  2. Cloud Router
  3. Dedicated Interconnect

3. Which one is better, VPC Peering or VPN?

ANS: – It depends on VPC peering is generally the better choice for connecting VPCs within the same project or region. At the same time, VPN is a good choice for connecting VPCs across different regions or locations or when security is a top priority. Ultimately, the best choice will depend on your specific requirements and network architecture.

WRITTEN BY Rakshit Joshi

Rakshit Joshi is working as a Research Associate in CloudThat. He is part of the DevOps vertical and is interested in learning new Cloud services and DevOps technologies.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!