Skip to content

mostafizur99/gcp-vpc-peering-nginx-access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Google Cloud VPC Network Peering to Connect Two VMs and Check Nginx Server Access.

Description

Explore hands-on VPC network peering within Google Cloud Platform (GCP). We'll create separate VPCs in different regions, set up VMs in each VPC, and deploy an Nginx server. And then, we will establish a connection between two VMs using VPC network peering.

Overview Diagram

vpc-peering-overview

Prerequisites

  • Google Cloud Platform(GCP) account or playground.
  • Knowledge about VPC, VM instance, Subnet, Network interface.

Hands On:

Create Two VPCs:

Creating vpc-1
vpc1-1 vpc1-2 vpc1-3 vpc1-4
Creating vpc-2
vpc1-1 vpc1-2 vpc1-3 vpc1-4

Now we can see the vpc-1 and vpc-2 are in the list.

vpcs-total

Create Two VMs:

Creating vm-1
vm1-1 vm1-2 vm1-3 vm1-4 vm1-5
Creating vm-2
vm2-1 vm2-2 vm2-3 vm2-4 vm2-5

Now we can see the vm-1 and vm-2 list.

vms-total

Peering Two VPC:

Peering vpc-1 to vpc-2
peer-1
Peering vpc-2 to vpc-1
peer-2

Now we can see the two active network peering.

vms-total

Check Connection:

Now if we try to connect from vm-1 to the vm-2, it will be connected now.

Ping from vpc-1 to vpc-2
check-vpc-connection

Create Nginx at One VM And Access From Others:

Here we will install nginx at vm-1 and will try to access from vm-2.

  • At vm-1 terminal, use the following command.

    To update app:

    sudo apt update -y

    To install nginx:

    sudo apt install nginx

    To check nginx service status::

    systemctl status nginx

    We will get the output like:

nginx-status

  • Now we will try to access from vm-2 terminal:

    curl http://34.75.68.89

    We will get the output like:

nginx-response

And Finally we have got the nginx server response from vm-1 to vm-2.