

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建 Direct Connect 虚拟私有网关
<a name="create-virtual-private-gateway"></a>

虚拟私有网关必须附加到您要连接到的 VPC。您可以使用 Direct Connect 控制台或使用命令行或 API 创建虚拟私有网关，并将其挂载到 VPC。

**注意**  
如果您计划对 Direct Connect 网关和动态 VPN 连接使用虚拟私有网关，请将虚拟私有网关上的 ASN 设置为 VPN 连接的所需值。否则，虚拟私有网关上的 ASN 可以设置为任何允许的值。Direct Connect 网关会通过分配给它的 ASN 公布给所有连接的 VPC。

创建虚拟专用网关后，必须将其连接到您的 VPC。

**创建虚拟专用网关并将其连接到您的 VPC**

1. 访问 [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。否则，选择**自定义 ASN**并输入一个值。对于 16 位 ASN，该值必须在 64512 到 65534 范围内。对于 32 位 ASN，该值必须在 4200000000 到 4294967294 范围内。

1. 选择 **Create Virtual Private Gateway**。

1. 选择您已创建的虚拟专用网关，然后依次选择 **Actions**、**Attach to 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)