> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Transit Gateway Inter-Region Routing with MCR

> This help topic describes how to configure Megaport Cloud Router to provide centralized routing between AWS transit gateways in different regions using BGP.

export const Anchor = ({name}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Anchor -';
  if (name === undefined || name === null || name === 'undefined') {
    console.error(`${errorPrefix} \`name\` must have a value — rendering an empty string instead`);
    return <></>;
  }
  const raw = typeof name === 'string' ? name : JSON.stringify(name);
  const id = raw.replace(/\s+/g, '-').replace(/[^A-Za-z0-9_-]/g, '').replace(/-+/g, '-').replace(/^-+|-+$/g, '');
  if (!id) {
    console.error(`${errorPrefix} \`name\` "${name}" sanitizes to an empty id — rendering an empty string instead`);
    return <></>;
  }
  return <a style={{
    scrollMarginTop: 'var(--scroll-mt)'
  }} id={id}></a>;
};

export const Image = ({src, alt = '', caption, width, height, shadow}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Image -';
  if (typeof src !== 'string') {
    src = String(src);
  }
  if (!src || src === 'undefined') {
    console.error(`${errorPrefix} \`src\` is required — rendering an empty string instead`);
    return <></>;
  }
  const img = <img className={['mega-image-style', shadow ? 'shadow' : ''].join(' ')} src={src} alt={alt} width={width} height={height} style={{
    display: 'block'
  }} />;
  return caption ? <figure>
      {img}
      <figcaption style={{
    textAlign: 'center',
    width
  }}>{caption}</figcaption>
    </figure> : img;
};

export const Link = ({href, children}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Link -';
  if (typeof href !== 'string') {
    href = String(href);
  }
  if (!href || href === 'undefined') {
    console.error(`${errorPrefix} the \`href\` property is required — rendering an empty string instead`);
    return <></>;
  }
  if (href.includes('{') || href.toUpperCase().includes('%7B')) {
    console.error(`${errorPrefix} could not resolve a variable in href "${href}" — rendering an empty string instead`);
    return <></>;
  }
  const isExternal = (/^https?:\/\//).test(href);
  return <a href={href} className="link" target={isExternal ? '_blank' : undefined} rel={isExternal ? 'noreferrer' : undefined}>
      {children ?? href}
      {isExternal && <span className="sr-only"> (opens in a new tab)</span>}
    </a>;
};

You can configure Megaport Cloud Router (MCR) to provide centralized routing between transit gateways in different regions using BGP to advertise routes dynamically.

This topic describes a sample configuration and explains each of these steps:

* [Creating an MCR](#creating-an-mcr)
* [Creating VXCs to AWS Hosted Connect](#creating-vxcs-to-aws-hosted-connect)
* [Accepting the Hosted Connection](#accepting-the-hosted-connection)
* [Creating the Direct Connect gateways](#creating-the-direct-connect-gateways)
* [Creating a transit virtual interface between the MCR and each Direct Connect gateway](#creating-a-transit-virtual-interface-between-the-mcr-and-each-direct-connect-gateway)
* [Configuring BGP between the MCR and each Direct Connect gateway](#configuring-bgp-between-the-mcr-and-each-direct-connect-gateway)
* [Creating a transit gateway](#creating-a-transit-gateway)
* [Attaching your VPCs to the transit gateway](#attaching-your-vpcs-to-the-transit-gateway)
* [Attaching your transit gateway to the Direct Connect gateway](#attaching-your-transit-gateway-to-the-direct-connect-gateway)
* [Verifying route tables](#verifying-route-tables)

<Image src="/images/cloud/mcr/aws-transit-design.png" alt="MCR routing for inter-region transit gateways" width={700} />

## Prerequisites

Before proceeding, ensure you have the following:

* One or more VPCs in each region.\
  The VPCs cannot have overlapping CIDRs.
* AWS account number(s) associated with the transit gateways
* Five private, non-overlapping autonomous system numbers (ASNs).\
  The supported range is 64512 to 65534 for 16-bit ASNs and 4200000000 to 4294967294 for 32-bit ASNs.

  The examples in this topic use these values:

  | **MCR/Gateway** | **ASN** |
  | --------------- | ------- |
  | mcr-va-01       | 65001   |
  | dx-gwy1         | 65101   |
  | dx-gwy2         | 65102   |
  | tgw-us-west2    | 65103   |
  | tgw-us-east1    | 65104   |

<Anchor name="creating-an-mcr" />

## Creating an MCR

For this example, you will create a 2.5 Gbps MCR in the Coresite VA1 data center.\
For more information about this process, see [Creating an MCR](/mcr/creating-mcr).

**To create an MCR**

1. Log in to the <Link href="https://portal.megaport.com">Megaport Portal</Link> and choose **Services**.

2. Click **Add Services**, then select **MCR**.
   <Image src="/images/snippets/add-services-button.png" alt="Add Services button" shadow={true} width={150} />

3. Select the preferred data center location for the MCR and click **Next**.
   For this example, in the **Search** field enter *Reston*, choose Coresite VA1, and click **Next**.

4. Specify the MCR details.

   * **Rate Limit** -- Select 2.5 Gbps.
   * **MCR Name** -- Enter a name. This example configuration uses *mcr-va-01*.
   * **Minimum Term** -- Choose 12 months.
   * **Service Level Reference** (optional) -- Specify a unique identifying number for your Megaport service to be used for billing purposes, such as a cost center number, unique customer ID, or purchase order number. The service level reference number appears for each service under the Product section of the invoice. You can also edit this field for an existing service.
   * **MCR ASN** -- Override the default ASN and enter *65001*.
   * **BGP Default State** -- Leave as Enabled.
   * **Resource Tags** -- Add your own reference information if required.

5. Click **Next**.

6. Confirm the selected options and click **Add MCR**.

7. Click **Review Order** to proceed through the checkout process, or click **Save** to save the configured services before placing the order.

8. Review the Important Information section and confirm agreement with the Service Agreements.

   If you do not have a promotion code, skip to the **Order Now** step. If you do have a promotion code, enter it into the **Enter discount code** field then click **Apply**. Alternatively, if a code already appears in the **Discounts** field, verify it is correct and click **Apply**.

   The promotional discount appears below the Standard Term discount.  This discount is not reflected in the Monthly Rate shown here, it is applied at the time of billing.  If an invalid or expired code causes an error with your order, contact your Megaport Account Manager for a replacement code.

   <Image src="/images/snippets/add-promo-code.png" alt="Add Promo Code" shadow={true} width={750} />

   If you entered an incorrect promotion code, you can remove it by clicking **Remove**.

9. Click **Order Now**.

Wait a few moments for the MCR to be deployed. When deployed, the MCR icon changes to green indicating the MCR is ready for Virtual Cross Connects (VXCs).

<Anchor name="creating-vxcs-to-aws-hosted-connect" />

## Creating VXCs to AWS Hosted Connect

With the new MCR, you want to create two VXC connections: one for each diversity zone.\
For more information about this process, see [Creating an MCR VXC](/mcr/mcr-vxc).

**To create a VXC to AWS Hosted Connect**

1. From the Services page of the <Link href="https://portal.megaport.com">Megaport Portal</Link>, select the newly created MCR.
2. Click the Amazon Web Services tile.
3. Select Hosted Connection as the AWS Connection Type.\
   A list of available AWS Hosted Connect locations appear.
4. Enter **USA** in the Select Destination Port search field, click the red diversity zone icon, then select US East (N. Virginia) CoreSite VA1, Reston, USA.
5. Click **Next**.
6. Specify the details for the VXC.
   * **Connection Name** - Name the connection *mcr-va-01 to dxgwy1*.
   * **Rate Limit** - Choose 1 Gbps.
   * **Minimum Term** - Choose 12 months.
   * **Resource Tags** - Add your own reference information if required.
7. Click **Next**.
8. For now, skip the MCR Connection detail (we will come back to it later) and click **Next**.
9. Enter your account ID in the **AWS Account ID** field then click **Next**.
10. Click **Add VXC**.

Repeat these steps to create a second VXC, but instead click the blue Diversity Zone icon and select US East (N. Virginia) Coresite VA1. Name the connection *mcr-va-01 to dxgwy2*.

On the right side of the Services page, the two VXCs appear as Configured Services. Click **Review Order**, review the Megaport Global Services Agreement, then click **Order Now**.

The Megaport Portal displays the Services page, where both VXCs appear and transition from a deployable to configured state. Once the VXCs are provisioned, their icons change to green, signifying they are ready for service.

The next steps are in the AWS console to:

* Accept the Hosted Connections
* Create the Direct Connect Gateways
* Create the transit gateways
* Create the transit VIF
* Attach your VPCs to each transit gateway

<Anchor name="accepting-the-hosted-connection" />

## Accepting the Hosted Connection

You must accept a Hosted Connection before you can begin using it.
Follow the steps for accepting a Hosted Connection from the [AWS Direct Connect User Guide](https://docs.aws.amazon.com/directconnect/latest/UserGuide/accept-hosted-connection.html).

1. Open the [Amazon Direct Connect console](https://console.aws.amazon.com/directconnect/v2/home).

2. Go to **Services > AWS Direct Connect > Connections**.

3. Click the ID of the connection named *mcr-va-01 to dxgwy1*.

4. Click **Accept** on the top right and **Confirm** in the Accept Hosted connection confirmation window.

5. Repeat the steps to accept the second connection named *mcr-va-01 to dxgwy2*.

Each connection will transition from a pending to available state.

<Anchor name="creating-the-direct-connect-gateways" />

## Creating the Direct Connect gateways

Direct Connect gateways are global resources, which means they can be used by resources in any commercial AWS region. Each Direct Connect gateway is its own ASN. In our sample configuration, we create multiple Direct Connect gateways with unique ASNs to allow routing between transit gateways in the different regions.

We will follow the steps for [creating a Direct Connect gateway](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-gateways-intro.html#create-direct-connect-gateway).

1. Choose Direct Connect Gateways from the navigation pane on the left, and then click **Create Direct Connect Gateway**.

2. Enter the Name and Amazon side ASN: our example uses *dx-gwy1* and *65101*.

3. Click **Create**.

4. Repeat this process for a second Direct Connect gateway with *dx-gwy2* for the name and *65102* for the Amazon-side ASN.

<Anchor name="creating-a-transit-virtual-interface-between-the-mcr-and-each-direct-connect-gateway" />

## Creating a transit virtual interface between the MCR and each Direct Connect gateway

These steps follow those outlined [for creating a transit virtual interface to the Direct Connect gateway](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-transit-gateways.html) from the AWS Direct Connect User Guide.

1. In the AWS console, choose Connections from the navigation pane on the left, and then click the ID of the connection for *mcr-va-01 to dxgwy1*.
2. In the navigation pane, choose Virtual interfaces.
3. Click **Create virtual interface**.
4. Choose Transit as your Virtual interface type.
5. Under Transit virtual interface settings, enter *tvif-dxgwy1* for the Virtual interface name.\
   The Connection and VLAN fields are pre-populated.
6. Under the Virtual interface owner, select My AWS account.
7. In the Direct Connect gateway drop-down, select *dx-gwy1*.\
   The **BGP ASN** field is the ASN of the MCR, which is *65001*.
   You do not need to change the other settings.
8. Scroll to the bottom and click **Create virtual interface**.
   A message appears confirming that the virtual interface was created successfully.
9. Click the ID of the newly created Virtual interface to display the Peerings information. Take note of the values for the BGP authentication key, your router IP, and the Amazon router IP. You will need these to finish configuring the MCR.

Repeat these steps for the transit virtual interface between the MCR and *dx-gwy2* and name the virtual interface *tvif-dxgwy2*.

<Anchor name="configuring-bgp-between-the-mcr-and-each-direct-connect-gateway" />

## Configuring BGP between the MCR and each Direct Connect gateway

1. In the <Link href="https://portal.megaport.com">Megaport Portal</Link>, go to the **Services** page.

2. Select the MCR you want to use.

3. Locate the VXC titled *mcr-va-01 to dxgwy1*, click the green VXC icon, and click **Next**.

4. In the **Interface IP Addresses** field, enter the value for the router IP (subnet mask included) that you previously copied from the AWS Direct Connect console.

5. Click **Add BGP Connection**.

6. Enter the following values:

   * **Local IP** -- Select the value you just entered from the drop-down list.
   * **Peer IP** -- Enter the Amazon router IP value (without the subnet mask).
   * **Peer ASN** -- Enter the ASN of *dxgwy1*, which is *65101*.
   * **BGP Password** -- Enter the BGP authentication key from the AWS console.

7. Click **Add**, click **Save**, and then click **Close**.

   <Note>
     It can take a couple minutes for the updates to be reflected in the Portal.
   </Note>

Repeat these steps for the VXC to *dxgwy2* and *tvif-dxgwy2*. Use the ASN value of *65102*.

1. Locate the VXC titled *mcr-va-01 to dxgwy2*, click the green VXC icon, and click **Next**.

2. In the **Interface IP Addresses** field, enter the value for the router IP (subnet mask included) that you previously copied from the AWS Direct Connect console.

3. Click **Add BGP Connection**.

4. Enter the following values:

   * **Local IP** -- Select the value you just entered from the drop-down list.
   * **Peer IP** -- Enter the Amazon router IP value (without the subnet mask).
   * **Peer ASN** -- Enter the ASN of *dxgwy2*, which is *65102*.
   * **BGP Password** -- Enter the BGP authentication key from the AWS console.

5. Click **Add**, click **Save**, and then click **Close**.

Within 3 to 5 minutes, check the AWS Direct Connect console, and review the details of each transit virtual interface for the BGP status.

<Anchor name="creating-a-transit-gateway" />

## Creating a transit gateway

These steps follow those outlined for [creating a transit gateway](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-getting-started.html#step-create-tgw) from the Amazon Virtual Private Cloud Transit Gateways Guide.

1. Open the [Amazon VPC management console](https://console.aws.amazon.com/vpc/).

2. Select the region for your VPC.\
   For our example, select *us-west2*.

3. Choose Transit Gateways from the navigation pane on the left.

4. Click **Create Transit Gateway**.

5. Specify the following transit gateway details:
   * **Name tag** -- Give your transit gateway a friendly name. This example uses the name *tgw-us-west2*.
   * **Description** -- This field is optional.
   * **Amazon side ASN** -- Enter the autonomous system number for your transit gateway. Following the values defined in prerequisites, we will use *65103*.\
     The rest of the settings are optional. You can modify the default settings if you want to disable DNS support, or you don’t want to use the default route table. Leave the default values as they are.

6. Click **Create Transit Gateway**.

7. Wait for the request to succeed and click **Close**.\
   The initial state of the transit gateway is Pending.

Repeat these steps for the transit gateway in *us-east1*, with the name *tgw-us-east1*, and Amazon-side ASN *65104*.

<Anchor name="attaching-your-vpcs-to-the-transit-gateway" />

## Attaching your VPCs to the transit gateway

These steps follow those outlined for [attaching your VPCs to the transit gateway](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-getting-started.html#step-attach-vpcs) from the Amazon Virtual Private Cloud Transit Gateways Guide.

Before you complete these steps, wait for the state of your transit gateway to change to *available*. This might take 15 to 20 minutes to complete.

1. Make sure that the *us-west2* region is selected.
2. From the VPC console, scroll to the bottom and select Transit Gateway Attachments.
3. Choose Transit Gateway Attachments from the navigation pane on the left.
4. Select the transit gateway you created for the attachment from the Transit Gateway ID drop-down list.
5. Select VPC as the Attachment type.
6. Optionally, enter an attachment name.
7. DNS support is enabled by default; keep this setting.
8. Ensure that the **IPv6 support** check box is cleared.
9. Select the VPC to attach from the VPC ID drop-down list.
10. For Subnet IDs, select one subnet for each Availability Zone to be used by the transit gateway to route traffic.\
    You can select only one subnet per Availability Zone.
11. Click **Create attachment**.
12. Wait for the request to succeed, and then click **Close**.
13. Repeat these steps for the VPC in *us-east1*.

<Anchor name="attaching-your-transit-gateway-to-the-direct-connect-gateway" />

## Attaching your transit gateway to the Direct Connect gateway

These steps follow those outlined for [Transit Gateway Associations](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-transit-gateways.html) from the AWS Direct Connect User Guide.

1. Open the [Amazon VPC management console](https://console.aws.amazon.com/vpc/).
2. Select Direct Connect gateways from the navigation pane on the left.
3. Select the ID for the *dx-gwy1* Direct Connect gateway.
4. Choose Gateway associations.
5. Select the transit gateway you created (*tgw-us-west2*) from the Gateways drop-down list.
6. Enter the CIDR prefix of your VPCs in Allowed prefixes.\
   This tells the TGW what prefixes to advertise to the Direct Connect gateway. Up to 20 prefixes are permitted per transit gateway.
7. Click **Associate gateway**.
8. Repeat these steps for *dx-gwy2* and *tgw-us-east1*.

When complete, the state of the transit gateway association changes from *associating* to *available*.

<Anchor name="verifying-route-tables" />

## Verifying route tables

As the final step, verify the routing tables on each transit gateway.
These steps follow those outlined for [View Transit Gateway Route Tables](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-route-tables.html#view-tgw-route-tables) from the Amazon Virtual Private Cloud Transit Gateways Guide.

1. Open the [Amazon VPC management console](https://console.aws.amazon.com/vpc/).
2. Select the region for your VPC (our example uses *us-west2*).
3. Choose Transit Gateway Route Tables from the navigation pane on the left.
4. Select the **Routes** tab to see the route for the corresponding transit gateway learned from Direct Connect Gateway.
5. Repeat these steps for the transit gateway in *us-east1*.

## Using a service key

You can create a service key that allows you to share your service with another Megaport account holder.
For more information, see [Setting up Service Keys](/marketplace/service-keys/).
