

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 建立 Direct Connect 虛擬私有閘道
<a name="create-virtual-private-gateway"></a>

虛擬私有閘道必須連接至您要連接的 VPC。您可以使用主控台或使用命令列或 API Direct Connect 來建立虛擬私有閘道，並將其連接至 VPC。

**注意**  
如果您打算將虛擬私有閘道用於 Direct Connect 閘道及動態 VPN 連線，請將虛擬私有閘道上的 ASN 設定為需用於 VPN 連接的值。否則，請將虛擬私有閘道上的 ASN 設定為任何許可值。Direct Connect 閘道透過指派給它的 ASN 公告所有連線的 VPC。

在您建立虛擬私有閘道之後，您必須予以連接至您的 VPC。

**建立虛擬私有閘道並予以連接至您的 VPC**

1. 在 https：//[https://console.aws.amazon.com/directconnect/v2/home](https://console.aws.amazon.com/directconnect/v2/home) 開啟 **Direct Connect**主控台。

1. 在導覽窗格中，選擇**虛擬私有閘道**，然後選擇**建立虛擬私有閘道**。

1. (選用) 輸入您虛擬私有閘道的名稱。執行此作業會使用 `Name` 做為鍵，以及您指定的值來建立標籤。

1. 針對 **ASN**，保留預設選項以使用預設的 Amazon ASN。否則，請選擇 **Custom ASN (自訂 ASN)** 並輸入值。對於 16 位元的 ASN，此值的範圍必須為 64512 到 65534。對於 32 位元的 ASN，此值的範圍必須為 4200000000 到 4294967294。

1. 選擇 **Create Virtual Private Gateway** (建立虛擬私有閘道)。

1. 選取您建立的虛擬私有閘道，然後選擇 **Actions** (動作)、**Attach to VPC** (連接到 VPC)。

1. 從清單選取您的 VPC，然後選擇 **Yes, Attach** (是，連接)。

**使用命令列或 API 建立虛擬私有閘道**
+ [CreateVpnGateway](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVpnGateway.html) (Amazon EC2 查詢 API)
+ [create-vpn-gateway](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-vpn-gateway.html) (AWS CLI)
+ [New-EC2VpnGateway](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2VpnGateway.html) (AWS Tools for Windows PowerShell)

**使用命令列或 API 將虛擬私有閘道連接到 VPC**
+ [AttachVpnGateway](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVpnGateway.html) (Amazon EC2 查詢 API)
+ [attach-vpn-gateway](https://docs.aws.amazon.com/cli/latest/reference/ec2/attach-vpn-gateway.html) (AWS CLI)
+ [Add-EC2VpnGateway](https://docs.aws.amazon.com/powershell/latest/reference/items/Add-EC2VpnGateway.html) (AWS Tools for Windows PowerShell)