DEV Community

Cover image for TRANSIT GATEWAY
Nishita Mohanty
Nishita Mohanty

Posted on • Updated on

TRANSIT GATEWAY

How to connect multiple VPC's together??
There are 2 ways to connect multiple VPC's together:-
-> VPC PEERING
-> TRANSIT GATEWAY

What is Transit Gateway??
Transit Gateway is a service that enables us to connect their VPCs together as well as connect VPCs and their on-premises networks to a single gateway. It is used to establish communication in much simpler way.

What is VPC peering?
A VPC peering connection is a networking connection between several VPCs that enables us to route traffic between them using private IPv4 addresses or IPv6 addresses.

Why Transit Gateway is preferred over VPC Peering??
Drawback is if number of network increases then, our VPC peering also increases. Then it creates confusion.
There is a formula to establish peering connection:-
[n(n-1)]/2, where n represents number of networks/VPCs.

So, if we have 6 networks then according to the formula we are required to have 15 peering connections which is time consuming and creates confusion.

So, for this reason transit gateway is preferred over VPC peering.

DIAGRAM

Image description

How to establish connection among VPC's using transit gateway??
Step 1- Create 3 VPC's.
Image description
Step 2- Create SUBNETS for respective VPC's
Image description
Step 3- Make the subnet of VPC-1 as public subnet and make an Internet gateway and attach it to VPC-1 as we need to test the connection is communicating with other VPC's or not.

Image description
Image description

Image description
STEP 4- Create route tables for each subnet.
Image description

Image description
Image description
Image description

Now, create two more route tables for VPC-2 and VPC-3, then associate respective subnets.

STEP 5-
Now we want to test VPC-1 can communicate with VPC-2 and VPC-3 so for that we need to launch servers in respective VPC's.
**For VPC-2 and VPC-3 the servers are not required to have a public IP address.

Image description

STEP-6
We need Transit gateway to establish connections among the VPC's,
So, go to transit gateway,
Image description
Image description
Image description
Image description
Image description

STEP 7- Go to Transit Gateway Attachments,
Image description
Image description
Image description
Image description
Image description

Follow the above steps and make transit-gateway attachments for VPC-2 and VPC-3.
Image description
And wait for the attachments' state to be Available .

STEP 8- Go to Route table of VPC-1 and click on edit routes.
Image description
Image description
Image description

Now follow, the above steps and edit routes of VPC-2 and VPC-3.
->In route table of VPC-2, add CIDR range of VPC-1 and VPC-3.
->In route table of VPC-3, add CIDR range of VPC-1 and VPC-2.
Then click on save changes.

Now, we will use the server connected to VPC-1 (which is connected to internet gateway). From this server we will try to ping the other 2 servers. If pinging is successful then the established connection is working perfectly.
So, connect server of VPC-1 in Xshell.
then,
-> sudo su
-> cd
Then type ping 8.8.8.8 (to check it is connected to internet or not).
Image description
Now,
->type ping (private IP of server of VPC-2)
->type ping (private IP of server of VPC-3)

If we see pinging occurs then we are successful in building a connection between VPC-1 and other two VPCs.
Image description
We can see the pinging is happening so, the connection is successful.

Top comments (0)