Skip to main content

Connect multiple VPCs using Transit Gateway

KakaoCloud allows centralized traffic management between VPCs using Transit Gateway.

info
  • Estimated time: 60 minutes
  • User environment
    • Recommended OS: MacOS, Ubuntu
    • Region: kr-central-2
  • Prerequisites

About this scenario

In this scenario, you will create two VPCs and connect them using Transit Gateway. The steps include:

  1. Create two VPCs. Each VPC uses one AZ and the default public subnet.
  2. Create a Transit Gateway and attach both VPCs to it.
  3. Configure static routing in Transit Gateway to direct traffic to each VPC based on CIDR blocks.
  4. Configure subnet route tables to route traffic through Transit Gateway to reach the destination VPC.
  5. Create VM instances in each subnet and verify connectivity using the ping command.

The scenario architecture is illustrated below:

Image

Getting started

Step 1. Create VPC and subnets

VPCs provide logically isolated virtual network spaces, enabling flexible resource management on KakaoCloud. For more details, refer to the VPC documentation.

  1. Go to KakaoCloud Console > VPC and click [Create VPC].

  2. Create vpc-a using the following settings:

    Image

    ItemSub-itemValue
    VPC InformationVPC Namehandson-vpc-a
    VPC IP CIDR Block10.1.0.0/16
    Availability ZoneNumber of AZs1
    First AZkr-central-2-a
    Subnet ConfigurationNumber of public subnets per AZ1
    Number of private subnets per AZ0
  3. Create vpc-b using the following settings:

    caution

    Ensure the CIDR ranges of each VPC do not overlap. For example, if vpc-a uses 10.1.0.0/16, then vpc-b must use a distinct range like 10.2.0.0/16. Overlapping CIDR blocks will prevent communication between VPCs.

    Image

    ItemSub-itemValue
    VPC InformationVPC Namehandson-vpc-b
    VPC IP CIDR Block10.2.0.0/16
    Availability ZoneNumber of AZs1
    First AZkr-central-2-b
    Subnet ConfigurationNumber of public subnets per AZ1
    Number of private subnets per AZ0
  4. Go to KakaoCloud Console > VPC > Subnets and verify the created network resources.

Image

Step 2. Create and configure Transit Gateway

Transit Gateway simplifies the complexity of managing multiple VPC Peering connections by providing centralized traffic management for inter-VPC and VPC-to-on-premises traffic. For more details, refer to the Transit Gateway documentation.

1. Create Transit Gateway

  1. Go to KakaoCloud Console > Transit Gateway and click [Create Transit Gateway].

  2. Enter the following settings for the Transit Gateway:

    Image

    ItemDescription
    Transit Gateway Namehandson-transit-gateway
    Default AssociationEnabled
  3. Verify that the resource has been created successfully.

    Image

2. Create attachments

  1. Access the Attachment creation settings from the details page of the created Transit Gateway.

    Image

  2. Add handson-vpc-a as an Attachment to the Transit Gateway.

    Image

  3. Add handson-vpc-b as an Attachment to the Transit Gateway.

    Image

  4. Verify that the Attachments have been added successfully.

    Image

3. Configure Transit Gateway routing

  1. Access the Routing Table Details page connected to the Transit Gateway.

    Go to KakaoCloud Console > Transit Gateway > Transit Gateway List Table, or navigate to KakaoCloud Console > Transit Gateway > Route Table.

    Image

  2. In the Route tab, you can view static routes. Click [Add Static Route] to add a new route.

    Image

  3. Add a static route to direct traffic with the destination 10.1.0.0/16 to handson-vpc-a.

    Image

    ItemValue
    Destination10.1.0.0/16
    Targethandson-vpc-a
  4. Add another static route to direct traffic with the destination 10.2.0.0/16 to handson-vpc-b.

    Image

    ItemValue
    Destination10.2.0.0/16
    Targethandson-vpc-b
  5. Verify that the static routes have been configured correctly.

    Image

Step 3. Configure subnet route policies

  1. Navigate to Beyond Networking Service > VPC > Route Tables and check the list of route tables. Access the details of the main subnet's route table for both handson-vpc-a and handson-vpc-b, and modify the routing information.

    Image

  2. Access the route table details for the main subnet of handson-vpc-a. Click [Add Route] to add a new route.

    Image

  3. Add a route where the destination is the CIDR of handson-vpc-b, and set handson-transit-gateway as the target.

  4. Verify the added route information.

    Image

  5. Access the route table details for the main subnet of handson-vpc-b. Click [Add Route] to add a new route.

    Image

  6. Add a route where the destination is the CIDR of handson-vpc-a, and set handson-transit-gateway as the target.

    Image

  7. Verify the added route information.

    Image

Step 4. Create instances and verify connectivity

  1. Go to KakaoCloud Console > Virtual Machine > Instances and click [Add Instance] to create instances. Refer to the table below for the configurations.

    ItemSub-itemInstance 1Instance 2
    Basic InformationNamehandson-instance-ahandson-instance-b
    Count11
    ImageUbuntu 20.04Ubuntu 20.04
    Instance Typem2a.largem2a.large
    VolumeRoot volume, 20GB, SSDRoot volume, 20GB, SSD
    Key Pair{User Key Pair}{User Key Pair}
    NetworkVPChandson-vpc-ahandson-vpc-b
    Subnetmainhandson-vpc-b
    Security Group{Refer below}{Refer below}
  2. Configure security policies to enable communication. Refer to the table below:

    PolicyInboundInboundOutbound
    ProtocolICMPTCPALL
    Source10.0.0.0/8{User Public IP}/320.0.0.0/0
    Port Number-22-
    Policy Descriptionpingsshall
    info

    Use online tools like WhatIsMyIP.com to check your public IP address.

  3. Assign a public IP to the instance and connect via SSH.

    Connect via SSH
    ssh ubuntu@{INSTANCE_PUBLIC_IP} -i {KEY_PAIR}
  4. After connecting, verify communication between instances using the ping command. The image below shows the result of using ping from instance-a in vpc-a to instance-b in vpc-b.

    Ping from instance-a to instance-b
    ping {INSTANCE_PRIVATE_IP}

    Image

    The following image shows the result of using ping from instance-b in vpc-b to instance-a in vpc-a.

    Image