本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Amazon Direct Connect CLI
您可以使用 Amazon CLI 来创建和使用 Amazon Direct Connect 资源。
以下示例使用 Amazon CLI 命令创建 Amazon Direct Connect 连接。您也可以下载授权书和连接设施分配书 (LOA-CFA) 或配置私有或公共虚拟接口。
在开始之前,请确保您已经安装并配置 Amazon CLI。有关更多信息,请参阅 用户指南。Amazon Command Line Interface
步骤 1:创建连接
第一步是提交连接请求。确保您知道所需的端口速度和 Amazon Direct Connect 位置。有关更多信息,请参阅 专用和托管连接。
创建连接请求
-
描述您当前所在地区 Amazon Direct Connect 的地点。在返回的输出中,记录您要建立连接的位置的位置代码。
aws directconnect describe-locations
{ "locations": [ { "locationName": "City 1, United States", "locationCode": "Example Location 1" }, { "locationName": "City 2, United States", "locationCode": "Example location" } ] }
-
创建连接并指定名称、端口速度和位置代码。在返回的输出中,记录连接 ID。在下一步CFA中,你需要身份证才能获得 LOA-。
aws directconnect create-connection --location
Example location
--bandwidth1Gbps
--connection-name "Connection to AWS
"{ "ownerAccount": "123456789012", "connectionId": "dxcon-EXAMPLE", "connectionState": "requested", "bandwidth": "1Gbps", "location": "Example location", "connectionName": "Connection to AWS", "region": "sa-east-1" }
第 2 步:下载 LOA-CFA
在你请求连接之后,你可以CFA使用describe-loa
命令获取 LOA-。输出为 base64 编码。您必须提取相关LOA内容,对其进行解码并创建PDF文件。
要获取 LOA-CFA 使用 Linux 或 macOS
在此示例中,命令的最后一部分使用 base64 实用程序对内容进行解码,并将输出发送到文件中。PDF
aws directconnect describe-loa --connection-id
dxcon-fg31dyv6
--output text --query loaContent|base64 --decode >myLoaCfa
.pdf
要获取 LOA-CFA 使用 Windows
在此示例中,输出被提取到名为 myLoaCfa .base64 的文件中。第二个命令使用该certutil
实用程序对文件进行解码并将输出发送到PDF文件中。
aws directconneawsct describe-loa --connection-id
dxcon-fg31dyv6
--output text --query loaContent > myLoaCfa.base64
certutil -decode myLoaCfa.base64
myLoaCfa
.pdf
下载 LOA-后CFA,将其发送给您的网络提供商或托管服务提供商。
步骤 3:创建虚拟接口,获取路由器配置
下单 Amazon Direct Connect 连接后,必须创建一个虚拟接口才能开始使用。您可以创建私有虚拟接口来连接到您的VPC。或者,您可以创建一个公共虚拟接口来连接到不在中的 Amazon 服务VPC。您可以创建支持IPv4或IPv6流量的虚拟接口。
使用创建虚拟接口时 Amazon CLI,输出包括一般的路由器配置信息。要创建特定于您的设备的路由器配置,请使用 Amazon Direct Connect 控制台。有关更多信息,请参阅 下载路由器配置文件。
创建私有虚拟接口
-
获取连接到您的虚拟专用网关 (vgw-xxxxxxxx) 的 ID。VPC您需要该 ID 在下一步创建虚拟接口。
aws ec2 describe-vpn-gateways
{ "VpnGateways": [ { "State": "available", "Tags": [ { "Value": "DX_VGW", "Key": "Name" } ], "Type": "ipsec.1", "VpnGatewayId": "vgw-ebaa27db", "VpcAttachments": [ { "State": "attached", "VpcId": "vpc-24f33d4d" } ] } ] }
-
创建私有虚拟接口。必须指定名称、VLAN ID 和BGP自治系统编号 (ASN)。
对于IPv4流量,对等互BGP连会话的每一端都需要私有IPv4地址。您可以自己指定IPv4地址,也可以让 Amazon 为您生成地址。在以下示例中,将为您生成IPv4地址。
aws directconnect create-private-virtual-interface --connection-id
dxcon-fg31dyv6
--new-private-virtual-interface virtualInterfaceName=PrivateVirtualInterface
,vlan=101
,asn=65000
,virtualGatewayId=vgw-ebaa27db
,addressFamily=ipv4{ "virtualInterfaceState": "pending", "asn": 65000, "vlan": 101, "customerAddress": "192.168.1.2/30", "ownerAccount": "123456789012", "connectionId": "dxcon-fg31dyv6", "addressFamily": "ipv4", "virtualGatewayId": "vgw-ebaa27db", "virtualInterfaceId": "dxvif-ffhhk74f", "authKey": "asdf34example", "routeFilterPrefixes": [], "location": "Example location", "bgpPeers": [ { "bgpStatus": "down", "customerAddress": "192.168.1.2/30", "addressFamily": "ipv4", "authKey": "asdf34example", "bgpPeerState": "pending", "amazonAddress": "192.168.1.1/30", "asn": 65000 } "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-ffhhk74f\">\n <vlan>101</vlan>\n <customer_address>192.168.1.2/30</customer_address>\n <amazon_address>192.168.1.1/30</amazon_address>\n <bgp_asn>65000</bgp_asn>\n <bgp_auth_key>asdf34example</bgp_auth_key>\n <amazon_bgp_asn>7224</amazon_bgp_asn>\n <connection_type>private</connection_type>\n</logical_connection>\n", "amazonAddress": "192.168.1.1/30", "virtualInterfaceType": "private", "virtualInterfaceName": "PrivateVirtualInterface" }
要创建支持IPv6流量的私有虚拟接口,请使用与上述相同的命令并指定
ipv6
addressFamily
参数。您无法为对BGP等互连会话指定自己的IPv6地址;Amazon 会为您IPv6分配地址。 -
要按XML格式查看路由器配置信息,请描述您创建的虚拟接口。使用
--query
参数可提取customerRouterConfig
信息,使用--output
参数可将文本排列到以制表符分隔的行中。aws directconnect describe-virtual-interfaces --virtual-interface-id
dxvif-ffhhk74f
--query virtualInterfaces[*].customerRouterConfig --output text<?xml version="1.0" encoding="UTF-8"?> <logical_connection id="dxvif-ffhhk74f"> <vlan>101</vlan> <customer_address>192.168.1.2/30</customer_address> <amazon_address>192.168.1.1/30</amazon_address> <bgp_asn>65000</bgp_asn> <bgp_auth_key>asdf34example</bgp_auth_key> <amazon_bgp_asn>7224</amazon_bgp_asn> <connection_type>private</connection_type> </logical_connection>
创建公有虚拟接口
-
要创建公共虚拟接口,必须指定名称、VLAN ID 和BGP自治系统编号 (ASN)。
对于IPv4流量,您还必须为对等互BGP连会话的每一端指定公用IPv4地址,以及要发布的公共IPv4路由。BGP以下示例为IPv4流量创建了一个公共虚拟接口。
aws directconnect create-public-virtual-interface --connection-id
dxcon-fg31dyv6
--new-public-virtual-interface virtualInterfaceName=PublicVirtualInterface
,vlan=2000
,asn=65000
,amazonAddress=203.0.113.1/30
,customerAddress=203.0.113.2/30
,addressFamily=ipv4,routeFilterPrefixes=[{cidr=203.0.113.0/30
},{cidr=203.0.113.4/30
}]{ "virtualInterfaceState": "verifying", "asn": 65000, "vlan": 2000, "customerAddress": "203.0.113.2/30", "ownerAccount": "123456789012", "connectionId": "dxcon-fg31dyv6", "addressFamily": "ipv4", "virtualGatewayId": "", "virtualInterfaceId": "dxvif-fgh0hcrk", "authKey": "asdf34example", "routeFilterPrefixes": [ { "cidr": "203.0.113.0/30" }, { "cidr": "203.0.113.4/30" } ], "location": "Example location", "bgpPeers": [ { "bgpStatus": "down", "customerAddress": "203.0.113.2/30", "addressFamily": "ipv4", "authKey": "asdf34example", "bgpPeerState": "verifying", "amazonAddress": "203.0.113.1/30", "asn": 65000 } ], "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fgh0hcrk\">\n <vlan>2000</vlan>\n <customer_address>203.0.113.2/30</customer_address>\n <amazon_address>203.0.113.1/30</amazon_address>\n <bgp_asn>65000</bgp_asn>\n <bgp_auth_key>asdf34example</bgp_auth_key>\n <amazon_bgp_asn>7224</amazon_bgp_asn>\n <connection_type>public</connection_type>\n</logical_connection>\n", "amazonAddress": "203.0.113.1/30", "virtualInterfaceType": "public", "virtualInterfaceName": "PublicVirtualInterface" }
要创建支持IPv6流量的公共虚拟接口,您可以指定要通告的IPv6路由BGP。您无法为对等互连会话指定IPv6地址;Amazon 会为您分配IPv6地址。以下示例为IPv6流量创建了一个公共虚拟接口。
aws directconnect create-public-virtual-interface --connection-id
dxcon-fg31dyv6
--new-public-virtual-interface virtualInterfaceName=PublicVirtualInterface
,vlan=2000
,asn=65000
,addressFamily=ipv6,routeFilterPrefixes=[{cidr=2001:db8:64ce:ba00::/64
},{cidr=2001:db8:64ce:ba01::/64
}] -
要按XML格式查看路由器配置信息,请描述您创建的虚拟接口。使用
--query
参数可提取customerRouterConfig
信息,使用--output
参数可将文本排列到以制表符分隔的行中。aws directconnect describe-virtual-interfaces --virtual-interface-id
dxvif-fgh0hcrk
--query virtualInterfaces[*].customerRouterConfig --output text<?xml version="1.0" encoding="UTF-8"?> <logical_connection id="dxvif-fgh0hcrk"> <vlan>2000</vlan> <customer_address>203.0.113.2/30</customer_address> <amazon_address>203.0.113.1/30</amazon_address> <bgp_asn>65000</bgp_asn> <bgp_auth_key>asdf34example</bgp_auth_key> <amazon_bgp_asn>7224</amazon_bgp_asn> <connection_type>public</connection_type> </logical_connection>