Skip to main content

Connect multiple VPCs using Transit Gateway

KakaoCloud enables centralized management of inter-VPC traffic using Transit Gateway.

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

Introduce scenario

This scenario demonstrates creating two VPCs and connecting them using Transit Gateway. Details are as follows:

  1. Create two VPCs for connection. Each VPC uses one AZ and the default public subnet.
  2. Create a Transit Gateway and add the two VPCs as Attachments.
  3. Configure static routing on the Transit Gateway. Add a policy to route packets destined for specific VPC CIDRs to the corresponding VPC.
  4. Configure subnet route policies. Use the default public subnet and add a policy to route packets destined for the other VPC to the Transit Gateway. This enables connection to the destination VPC via the Transit Gateway.
  5. Create VM instances in each subnet and verify connectivity using the ping command.

The following is the architecture diagram for the scenario:

Image

Getting started

Step 1. Create VPCs and subnets

VPC provides a logically isolated virtual network space, enabling flexible resource management in KakaoCloud. See the VPC documentation for more details.

  1. Access the KakaoCloud Console > VPC, and click the [Create VPC] button.

  2. Refer to the table below to create vpc-a. Modify the VPC IP CIDR based on your environment as needed, and ensure all relevant values in the scenario are adjusted accordingly.

    Image

    ItemSub-itemValue
    VPC infoVPC namehandson-vpc-a
    VPC IP CIDR block10.1.0.0/16
    Availability zoneNumber of zones1
    First AZkr-central-2-a
    Subnet settingsPublic subnets per AZ1
    Private subnets per AZ0
  3. Refer to the table below to create vpc-b.

    caution

    Ensure the CIDR range of each VPC is unique to avoid conflicts that prevent communication. For instance, if VPC A uses 10.1.0.0/16, set VPC B to 10.2.0.0/16.

    Image

    ItemSub-itemValue
    VPC infoVPC namehandson-vpc-b
    VPC IP CIDR block10.2.0.0/16
    Availability zoneNumber of zones1
    First AZkr-central-2-b
    Subnet settingsPublic subnets per AZ1
    Private subnets per AZ0
  4. Go to KakaoCloud Console > VPC > Subnets to confirm the created network resources.

    Image

Step 2. Create and configure Transit Gateway

Transit Gateway simplifies inter-VPC and VPC-to-on-premises traffic management. See the Transit Gateway documentation for more details.

1. Create Transit Gateway

  1. Access KakaoCloud Console > Transit Gateway, and click the [Create Transit Gateway] button.

  2. Enter the following information based on the table and image below:

    Image

    ItemDescription
    Transit Gateway namehandson-transit-gateway
    Default connection (Association)Connection
    Shared acceptance settingsManual
  3. Verify that the resource has been created successfully.

    Image

2. Create Attachments

  1. In the Attachment menu, click [Create Attachment], and create an Attachment for handson-vpc-a using the table below:

    ItemDescription
    Resourcehandson-vpc-a
    Subnetkr-central-2-a
  2. Similarly, create an Attachment for handson-vpc-b:

    ItemDescription
    Resourcehandson-vpc-b
    Subnetkr-central-2-b
  3. Confirm that both Attachments have been added successfully.

    Image

3. Configure transit gateway routing

  1. Navigate to the KakaoCloud console > Transit Gateway > Routing table menu.

  2. Select the default connection routing table linked during transit gateway creation.

  3. In the Routing tab, click the [Add static routing] button and add the following static routing. This adds a rule to route traffic with destination 10.1.0.0/16 to handson-vpc-a through the transit gateway.

    ItemValue
    Destination10.1.0.0/16
    Targethandson-vpc-a
  4. Click the [Add static routing] button again to add a rule for routing traffic with destination 10.2.0.0/16 to handson-vpc-b through the transit gateway.

    ItemValue
    Destination10.2.0.0/16
    Targethandson-vpc-b
  5. Verify that the configurations have been added as planned.

Step 3. Configure subnet route policies

  1. Go to KakaoCloud Console > Beyond Networking Service > VPC > Routing Table, and check the list of routing tables.

  2. Update the routing table for the main subnet in handson-vpc-a:

    ItemValue
    Destination10.2.0.0/16
    Target typeTransit Gateway
    Target namehandson-transit-gateway
  3. Update the routing table for the main subnet in handson-vpc-b:

    ItemValue
    Destination10.1.0.0/16
    Target typeTransit Gateway
    Target namehandson-transit-gateway
  4. Confirm that the routing is Active.

Step 4. Create instances and verify connectivity

  1. Navigate to KakaoCloud Console > Virtual Machine > Instances, and create one instance in each VPC using the table below:

    ItemDetailsInstance 1Instance 2
    Namehandson-instance-ahandson-instance-b
    Number11
    ImageUbuntu 20.04Ubuntu 20.04
    Instance typem2a.largem2a.large
    VolumeRoot volume, 20GB SSDRoot volume, 20GB SSD
    Key pair{Your key pair}{Your key pair}
    NetworkVPChandson-vpc-ahandson-vpc-b
    SubnetMain subnet of handson-vpc-aMain subnet of handson-vpc-b
    Security group{See below}{See below}
  2. Add the following security group policies for connectivity:

    PolicyInboundInboundOutbound
    ProtocolICMPTCPALL
    Source10.0.0.0/8{Your public IP}/320.0.0.0/0
    Port-22-
    Descriptionpingsshall
    info

    To find your public IP address, visit WhatIsMyIP.com.

  3. Assign public IPs to the instances and access them via SSH:

    ssh ubuntu@{INSTANCE_PUBLIC_IP} -i {KEY_PAIR}
  4. Verify connectivity by using the ping command to test between instances in the two VPCs. Below is an example:

    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