OVERVIEW
Creating a network using the virtual private cloud service on AWS and connecting the network to another Virtual private cloud network to aid easy communication and exchange of resources between the networks
INTRODUCTION
I believe growing up we had friends and some of us belonged to peer groups where we had one or two people who shared similar interests. We can also apply this reasoning to networks with similar goals and objectives. To achieve these objectives resources would have to be exchanged to allow each network to play its part in the project properly. This is where you have to apply the concept of VPC peering.
VIRTUAL PRIVATE CLOUD (VPC)
Virtual Private Cloud has to do with the act of building your private network on the cloud and other resources are able to leverage the network. In other words, A virtual private cloud (VPC) is a secure, isolated private cloud hosted within a public cloud. VPC customers can run code, store data, host websites, and do anything else they could do in an ordinary private cloud, but the private cloud is hosted remotely by a public cloud provider.
It is important you know that we have other concepts under VPC which include subnets, IP Addressing, CIDR, Route Tables, Internet Gateway, NAT- Gateway and Elastic IP.
VPC PEERING
In simple terms, this is the communication between networks. The exchange of resources is easier when shared in the same network therefore creating the need for VPC peering which is the establishment of a connection whereby VPCs in different networks can share resources and communicate with each other.
PREREQUISITE
- An AWS account
- Knowledge of basic networking concepts (Subnets, Route Tables, Internet Gateway, IP Addressing, CIDR)
STEPS
i. Create a network using the AWS VPC service
- Log into your AWS console and use the search bar to search for VPC and click on it
- Click on Create VPC to create the first network in network peer
- Create the second network in the peer using the same VPC service
- select 'your VPCs' to see a list of all the VPCs you have created to be paired together
ii. Create Subnets for the networks you created (for this report we will be creating only public subnets)
Go to subnet under your VPC dashboard and click Create Subnet
While creating the first and second subnets select the Correct VPC you are creating
- select 'subnets' to see a list of all the sub-networks you have created
iii. Create Route tables for both networks
- Go to Route tables under your VPC dashboard and click Create a route table
- Create route tables for both networks that is VPC 1 and VPC 2
- Select route tables to get a list of all subnets you have created
iv. Create Internet Gateway for both networks because we are working with public subnets
- Go to Internet Gateway under your VPC dashboard and click Create Internet
- Create IGW for both networks and attach to their respective networks
- Select internet gateway to get a list of all IGWs you have created
v.Edit Routes and subnet association
-Add route and set it to 0.0.0.0/0 then afterwards select next box, pick Interner Gateway, and finally select the IGW you created for that particular network. Save changes afterwards.
- select subnet association and click on edit subnet association
- Select the subnet for that route table and save the association
-Carry out these configurations on both networks to be paired together.
vi. Create Elastic Compute Cloud (Ec2) Instances for both networks
- Go to the search bar and type Ec2 then click on Ec2
- Click on launch instance to create your virtual server
-Input the name of your server, select Amazon Linux as your Amazon machine image, and leave instance type as default because it's one of the free tier available instance types
Create a login key that will be used to access your server. Next, you edit network settings and link your server to the VPC you created. Then select auto-assign public IP because it is a public subnet.
Leave all other settings on default then lunch instance
- Apply all the procedures stated above and create another server for your second network
vii. VPC Peering
- use the search bar to search for VPC and click on it
- Scroll down the list of services under VPC and select peering connection
- Click on create peering connection
-Select the first VPC as requester VPC
-select the second VPC as the accepter VPC. please if the accepted is in another region or another account this is where you specify the location of your second VPC
-The requester VPC will have to be accepted by the accepter VPC so there is need to configure this. Simply click on actions and select accept the peering connection request
-Edit the routes between the two VPCs. This will be done in two places for the two VPCs that are being connected
- After selecting modify route tables, click on first route table created for first VPC and add destination. Add a route, CIDR will be the CIDR of second VPC and next select the peering connection then save changes.
-Go through similar steps for second route table
Viii. Connect your Instance to command line to test the peering connection
-Go to the first instance you created and click on it. After highlighting your instance, click on connect to connect it to the command line.
- To connect, select EC2 instance connect and scroll down and click on connect.
- On the command line run the command curl alongside the private IP address of your second server and the contents of the second second should come up and this means the connection is successful.
Conclusion
In conclusion, in this article we have successfully covered the concept behind VPC peering which is simply an AWS service that enables you to connect two or more VPCs in different AWS accounts or in the same AWS account and also the benefits of VPC peering which includes improved scalability, private connectivity, and ability to communicate between two different networks. If you need to communicate between two networks the most effective method is through peering the networks using the VPC peering service on AWS and to carry this out properly you should use this article as a guide.
Top comments (5)
Nicely done
Insightful, nice share
Nice work, well put together đź‘Šđź‘Ź
This was simplified in the best way possible.
Lovely