VPC Peering

Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

VPC Peering

What is VPC in AWS?

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS
resources into a virtual network that you've defined. This virtual network closely resembles
a traditional network that you'd operate in your own data Centre, with the benefits of using
the scalable infrastructure of AWS.

What is VPC and what are its benefits?

Benefit of VPC is that it helps in aspects of cloud computing like privacy,


security and preventing loss of proprietary data. Let’s take a look at some of the basics of a
VPC. Subnets: A subnet can be thought of as dividing a large network into smaller networks.

What is VPC Peering?

A VPC peering connection is a networking connection between two VPCs


that enables you to route traffic between them using private IPv4 addresses or IPv6
addresses. Instances in either VPC can communicate with each other as if they are within
the same network. You can create a VPC peering connection between your own VPCs, or
with a VPC in another AWS account.

For VPC peering follows the two steps:

• Create two VPC in different region


• Create three instance (one should public and another two instance private)
• Now the two private instance should share the data or between the two
private subnets.
VPC – Virtual Private Cloud

In this topic we are going to see how the VPC created in Linux Machine.

Steps to be followed
• Create VPC
• Create subnets
• Create IGW(Internet Gate Way)
• Create Route table
• Create Peering VPC
• Create security groups
• Create instance

In services under networking and content delivery VPC

STEP 1: Create VPC


STEP 2:

Create subnets

In the subnets we have two types

• Public
• Private

Create Public Subnets:


Create private subnets:
STEP 3: Create IGW
Now attach the IGW to the VPC
STEP 4: Route Table

• Public routing table


• Private routing table

First public
Choose the Public Route table and assign the subnet to it by editing. Then save it.

Choose the Route table and edit it with below data by adding another Route. Assign the
Internet Gateway to it. Then save it.
Then now create private RT
Same like, Create Private Route Table, associate Subnet & leave the Route rules without
assigning any.
\

STEP 5: Create NAT Gateway


Choose the Routes tab and edit it with below data by adding another Route. Assign the NAT
Gateway to it. Then save it.
Create a New Elastic IP
Sometime later the NAT gateway becomes available.

Go to Private Route table & edit the route. Map the NAT gateway to it.

Check NAT gateway became available,


STEP 6: Create security groups

• Public
• Private
For private
Copy the public SG ID
Choose it and change the inbound Rules of it by editing & save it.

STEP 7: Create instance

• Create Two EC2’s - one in public subnet, one in Private subnet


• Choose the VPC/Subnet/ Enable Auto Assigned IP address for
public and disable for private to the instance
Now map the security group public to public and private to private then launch
the EC2 instance

Choose the existing security groups

Select the security for private

Same for private machine also


Now you can see the ec2 instance

For public IP address shows


For private instance

Only show the private IP

Now logging into public machine via putty (file ppk)

In another method via pageant also

Now login to public instance

Log on to ec2-user
Then go to root user

Now check the public machine have internet is available or not

Use ping google.com

Create a new folder (vi test.pem)


And save it using (:wq!)

Then give the permission to the pem file


Now connect the private instance through public instance using these
commands.

Then converted into root user

Now we check the Internet connection in Private machine using these


commands.
Now create the VPC peering connection

Go to VPC service

Now create the VPC peering

Then create the subnet for private only


Now create the IGW for VPC2
Now attaché to VPC
Now create the Route table for VPC2 only for public & private
Now go Associated the subnet

Same for public also


Now routes
For private RT

Before that create Nat gateway


Create the NAT2 for VPC2
For VPC2 private route table
Now create the Peering Connection for two private

Tag for peering connection


Select the requester my-VPC

Now you can see the CIDR block

Now the accepter is VPC2


See the CIDR block for VPC2

Then Peering connection is Success

But view it is Pending access


To make active

Go to action

Press the accept request


Make it accept

Now you can see the peering connection is in active state

Then, now go to private route table for VPC1 & VPC2


Give the VPC2 Subnet ID

Give the Subnet ID for VPC1


Now create the EC2 instance

For VPC2 only private


Tasks: 1

• Creating and Accepting a VPC Peering Connection


• Rejecting a VPC Peering Connection
• Updating Your Route Tables for a VPC Peering Connection
• Updating Your Security Groups to Reference Peer VPC Groups
• Modifying VPC Peering Connection Options
• Deleting a VPC Peering Connection

Task: 2

Do in different region peering connection

Task: 3

Do this in different account

You might also like