创建和修改 ExpressRoute 线路的对等互连(经典)Create and modify peering for an ExpressRoute circuit (classic)

本文指导执行相关步骤,以便使用 PowerShell 和经典部署模型创建和管理 ExpressRoute 线路的对等互连/路由配置。This article walks you through the steps to create and manage peering/routing configuration for an ExpressRoute circuit using PowerShell and the classic deployment model. 下面的步骤还会说明如何查看状态,以及如何更新、删除和取消预配 ExpressRoute 线路的对等互连。The steps below will also show you how to check the status, update, or delete and deprovision peerings for an ExpressRoute circuit. 可以为 ExpressRoute 线路配置一个或两个对等互连(Azure 专用、Azure 公共)。You can configure one or two peerings (Azure private, Azure public) for an ExpressRoute circuit. 可以按照所选的任意顺序配置对等互连。You can configure peerings in any order you choose. 但是,必须确保一次只完成一个对等互连的配置。However, you must make sure that you complete the configuration of each peering one at a time.

这些说明仅适用于由提供第 2 层连接服务的服务提供商创建的线路。These instructions only apply to circuits created with service providers that offer Layer 2 connectivity services. 如果服务提供商提供第 3 层托管服务(通常是 IPVPN,如 MPLS),则连接服务提供商会配置和管理路由。If you are using a service provider that offers managed Layer 3 services (typically an IPVPN, like MPLS), your connectivity provider will configure and manage routing for you.

Important

从 2017 年 3 月 1 日开始,将无法在经典部署模型中创建新的 ExpressRoute 线路。As of March 1, 2017, you can't create new ExpressRoute circuits in the classic deployment model.

  • 可以将现有的 ExpressRoute 线路从经典部署模型移到 Resource Manager 部署模型,不会遇到连接中断问题。You can move an existing ExpressRoute circuit from the classic deployment model to the Resource Manager deployment model without experiencing any connectivity down time. 有关详细信息,请参阅移动现有线路For more information, see Move an existing circuit.
  • allowClassicOperations 设置为 TRUE 即可在经典部署模型中连接到虚拟网络。You can connect to virtual networks in the classic deployment model by setting allowClassicOperations to TRUE.

请使用以下链接在 Resource Manager 部署模型中创建和管理 ExpressRoute 线路:Use the following links to create and manage ExpressRoute circuits in the Resource Manager deployment model:

关于 Azure 部署模型About Azure deployment models

Azure 当前使用两种部署模型:资源管理器部署模型和经典部署模型。Azure currently works with two deployment models: Resource Manager and classic. 这两个模型不是完全兼容的。The two models are not completely compatible with each other. 在开始之前,需要知道所要使用的模型。Before you begin, you need to know which model that you want to work in. 有关部署模型的信息,请参阅了解部署模型For information about the deployment models, see Understanding deployment models. 如果不熟悉 Azure,建议使用 Resource Manager 部署模型。If you are new to Azure, we recommend that you use the Resource Manager deployment model.

Note

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

配置先决条件Configuration prerequisites

  • 在开始配置之前,请务必查看先决条件页、路由要求页和工作流页。Make sure that you have reviewed the prerequisites page, the routing requirements page and the workflows page before you begin configuration.
  • 必须有一个活动的 ExpressRoute 线路。You must have an active ExpressRoute circuit. 在继续下一步之前,请按说明 创建 ExpressRoute 线路,并通过连接提供商启用该线路。Follow the instructions to create an ExpressRoute circuit and have the circuit enabled by your connectivity provider before you proceed. ExpressRoute 线路必须处于已预配和已启用状态,才能运行下述 cmdlet。The ExpressRoute circuit must be in a provisioned and enabled state for you to be able to run the cmdlets described below.

下载最新的 PowerShell cmdletDownload the latest PowerShell cmdlets

安装最新版本的 Azure 服务管理 (SM) PowerShell 模块和 ExpressRoute 模块。Install the latest versions of the Azure Service Management (SM) PowerShell modules and the ExpressRoute module. 使用以下示例时,请注意,当更新版本的 cmdlet 发布时,版本号(在此示例中为 5.1.1)将更改。When using the following example, note that the version number (in this example, 5.1.1) will change as newer versions of the cmdlets are released.

Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\Azure\Azure.psd1'
Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\ExpressRoute\ExpressRoute.psd1'

有关详细信息,请参阅 Azure PowerShell cmdlet 入门,其中提供了有关如何配置计算机以使用 Azure PowerShell 模块的分步指导。For more information, see Getting started with Azure PowerShell cmdlets for step-by-step guidance on how to configure your computer to use the Azure PowerShell modules.

登录Sign in

若要登录到 Azure 帐户,请使用以下示例:To sign in to your Azure account, use the following examples:

  1. 使用提升的权限打开 PowerShell 控制台,并连接到帐户。Open your PowerShell console with elevated rights and connect to your account.

    Connect-AzAccount -Environment AzureChinaCloud
    
  2. 检查该帐户的订阅。Check the subscriptions for the account.

    Get-AzSubscription
    
  3. 如果有多个订阅,请选择要使用的订阅。If you have more than one subscription, select the subscription that you want to use.

    Select-AzSubscription -SubscriptionName "Replace_with_your_subscription_name"
    
  4. 接下来,使用以下 cmdlet 将 Azure 订阅添加到经典部署模型的 PowerShell。Next, use the following cmdlet to add your Azure subscription to PowerShell for the classic deployment model.

    Add-AzureAccount  -Environment AzureChinaCloud
    

Azure 专用对等互连Azure private peering

本部分说明如何为 ExpressRoute 线路创建、获取、更新和删除 Azure 专用对等互连配置。This section provides instructions on how to create, get, update, and delete the Azure private peering configuration for an ExpressRoute circuit.

创建 Azure 专用对等互连To create Azure private peering

  1. 创建 ExpressRoute 线路。Create an ExpressRoute circuit.

    请按说明创建 ExpressRoute 线路 ,并由连接服务提供商进行预配。Follow the instructions to create an ExpressRoute circuit and have it provisioned by the connectivity provider. 如果连接服务提供商提供第 3 层托管服务,可以请求连接服务提供商启用 Azure 专用对等互连。If your connectivity provider offers managed Layer 3 services, you can request your connectivity provider to enable Azure private peering for you. 在这种情况下,不需要遵循后续部分中所列的说明。In that case, you won't need to follow instructions listed in the next sections. 但是,如果连接服务提供商不管理路由,请在创建线路后遵循以下说明。However, if your connectivity provider does not manage routing for you, after creating your circuit, follow the instructions below.

  2. 检查 ExpressRoute 线路以确保它已预配。Check the ExpressRoute circuit to make sure it is provisioned.

    检查 ExpressRoute 线路是否已预配并已启用。Check to see if the ExpressRoute circuit is Provisioned and also Enabled.

    Get-AzureDedicatedCircuit -ServiceKey "*********************************"
    

    返回:Return:

    Bandwidth                        : 200
    CircuitName                      : MyTestCircuit
    Location                         : Beijing
    ServiceKey                       : *********************************
    ServiceProviderName              : Beijing Telecom Ethernet
    ServiceProviderProvisioningState : Provisioned
    Sku                              : Standard
    Status                           : Enabled
    

    确保线路显示为已预配并已启用。Make sure that the circuit shows as Provisioned and Enabled. 否则,请咨询连接服务提供商,使线路处于所需状态。If it isn't, work with your connectivity provider to get your circuit to the required state and status.

    ServiceProviderProvisioningState : Provisioned
    Status                           : Enabled
    
  3. 配置线路的 Azure 专用对等互连。Configure Azure private peering for the circuit.

    在继续执行后续步骤之前,请确保已准备好以下各项:Make sure that you have the following items before you proceed with the next steps:

    • 主链路的 /30 子网。A /30 subnet for the primary link. 它不能是保留给虚拟网络使用的任何地址空间的一部分。This must not be part of any address space reserved for virtual networks.
    • 辅助链路的 /30 子网。A /30 subnet for the secondary link. 它不能是保留给虚拟网络使用的任何地址空间的一部分。This must not be part of any address space reserved for virtual networks.
    • 用于建立此对等互连的有效 VLAN ID。A valid VLAN ID to establish this peering on. 确认线路中没有其他对等互连使用同一个 VLAN ID。Verify that no other peering in the circuit uses the same VLAN ID.
    • 对等互连的 AS 编号。AS number for peering. 可以使用 2 字节和 4 字节 AS 编号。You can use both 2-byte and 4-byte AS numbers. 可以将专用 AS 编号用于此对等互连。You can use a private AS number for this peering. 确认未使用 65515。Verify that you are not using 65515.
    • MD5 哈希(如果选择使用)。An MD5 hash if you choose to use one. 可选。Optional.

    可使用以下示例为线路配置 Azure 专用对等互连:You can use the following example to configure Azure private peering for your circuit:

    New-AzureBGPPeering -AccessType Private -ServiceKey "*********************************" -PrimaryPeerSubnet "10.0.0.0/30" -SecondaryPeerSubnet "10.0.0.4/30" -PeerAsn 1234 -VlanId 100
    

    若要使用 MD5 哈希,请使用以下示例为线路配置 Azure 专用对等互连:If you want to use an MD5 hash, use the following example to configure private peering for your circuit:

    New-AzureBGPPeering -AccessType Private -ServiceKey "*********************************" -PrimaryPeerSubnet "10.0.0.0/30" -SecondaryPeerSubnet "10.0.0.4/30" -PeerAsn 1234 -VlanId 100 -SharedKey "A1B2C3D4"
    

    Important

    确认将 AS 编号指定为对等互连 ASN 而不是客户 ASN。

查看 Azure 专用对等互连详细信息To view Azure private peering details

可使用以下 cmdlet 来查看配置详细信息:You can view configuration details using the following cmdlet:

Get-AzureBGPPeering -AccessType Private -ServiceKey "*********************************"

返回:Return:

AdvertisedPublicPrefixes       : 
AdvertisedPublicPrefixesState  : Configured
AzureAsn                       : 12076
CustomerAutonomousSystemNumber : 
PeerAsn                        : 1234
PrimaryAzurePort               : 
PrimaryPeerSubnet              : 10.0.0.0/30
RoutingRegistryName            : 
SecondaryAzurePort             : 
SecondaryPeerSubnet            : 10.0.0.4/30
State                          : Enabled
VlanId                         : 100

更新 Azure 专用对等互连配置To update Azure private peering configuration

可以使用以下 cmdlet 更新配置的任何部分。You can update any part of the configuration using the following cmdlet. 在以下示例中,线路的 VLAN ID 将从 100 更新为 500。In the following example, the VLAN ID of the circuit is being updated from 100 to 500.

Set-AzureBGPPeering -AccessType Private -ServiceKey "*********************************" -PrimaryPeerSubnet "10.0.0.0/30" -SecondaryPeerSubnet "10.0.0.4/30" -PeerAsn 1234 -VlanId 500 -SharedKey "A1B2C3D4"

删除 Azure 专用对等互连To delete Azure private peering

可以运行以下 cmdlet 删除对等互连配置。You can remove your peering configuration by running the following cmdlet. 运行此 cmdlet 之前,必须确保已从 ExpressRoute 线路取消链接所有虚拟网络。You must make sure that all virtual networks are unlinked from the ExpressRoute circuit before running this cmdlet.

Remove-AzureBGPPeering -AccessType Private -ServiceKey "*********************************"

Azure 公共对等互连Azure public peering

本部分说明如何为 ExpressRoute 线路创建、获取、更新和删除 Azure 公共对等互连配置。This section provides instructions on how to create, get, update, and delete the Azure public peering configuration for an ExpressRoute circuit.

创建 Azure 公共对等互连To create Azure public peering

  1. 创建 ExpressRoute 线路Create an ExpressRoute circuit

    请按说明创建 ExpressRoute 线路 ,并由连接服务提供商进行预配。Follow the instructions to create an ExpressRoute circuit and have it provisioned by the connectivity provider. 如果连接服务提供商提供第 3 层托管服务,可以请求连接服务提供商启用 Azure 公共对等互连。If your connectivity provider offers managed Layer 3 services, you can request your connectivity provider to enable Azure public peering for you. 在这种情况下,不需要遵循后续部分中所列的说明。In that case, you won't need to follow instructions listed in the next sections. 但是,如果连接服务提供商不管理路由,请在创建线路后遵循以下说明。However, if your connectivity provider does not manage routing for you, after creating your circuit, follow the instructions below.

  2. 检查 ExpressRoute 线路以确认它已预配Check ExpressRoute circuit to verify that it is provisioned

    首先,必须检查 ExpressRoute 线路是否已预配且已启用。You must first check to see if the ExpressRoute circuit is Provisioned and also Enabled.

    Get-AzureDedicatedCircuit -ServiceKey "*********************************"
    

    返回:Return:

    Bandwidth                        : 200
    CircuitName                      : MyTestCircuit
    Location                         : Beijing
    ServiceKey                       : *********************************
    ServiceProviderName              : Beijing Telecom Ethernet
    ServiceProviderProvisioningState : Provisioned
    Sku                              : Standard
    Status                           : Enabled
    

    确认线路显示为已预配并已启用。Verify that the circuit shows as Provisioned and Enabled. 否则,请咨询连接服务提供商,使线路处于所需状态。If it isn't, work with your connectivity provider to get your circuit to the required state and status.

    ServiceProviderProvisioningState : Provisioned
    Status                           : Enabled
    
  3. 配置线路的 Azure 公共对等互连Configure Azure public peering for the circuit

    在继续下一步之前,请确保已准备好以下信息:Make sure that you have the following information before you proceed:

    • 主链路的 /30 子网。A /30 subnet for the primary link. 这必须是有效的公共 IPv4 前缀。This must be a valid public IPv4 prefix.
    • 辅助链路的 /30 子网。A /30 subnet for the secondary link. 这必须是有效的公共 IPv4 前缀。This must be a valid public IPv4 prefix.
    • 用于建立此对等互连的有效 VLAN ID。A valid VLAN ID to establish this peering on. 确认线路中没有其他对等互连使用同一个 VLAN ID。Verify that no other peering in the circuit uses the same VLAN ID.
    • 对等互连的 AS 编号。AS number for peering. 可以使用 2 字节和 4 字节 AS 编号。You can use both 2-byte and 4-byte AS numbers.
    • MD5 哈希(如果选择使用)。An MD5 hash if you choose to use one. 可选。Optional.

    Important

    请确保将 AS 编号指定为对等互连 ASN 而不是客户 ASN。

    可使用以下示例为线路配置 Azure 公共对等互连:You can use the following example to configure Azure public peering for your circuit:

    New-AzureBGPPeering -AccessType Public -ServiceKey "*********************************" -PrimaryPeerSubnet "131.107.0.0/30" -SecondaryPeerSubnet "131.107.0.4/30" -PeerAsn 1234 -VlanId 200
    

    若要使用 MD5 哈希,请使用以下示例配置线路:If you want to use an MD5 hash, use the following example to configure your circuit:

    New-AzureBGPPeering -AccessType Public -ServiceKey "*********************************" -PrimaryPeerSubnet "131.107.0.0/30" -SecondaryPeerSubnet "131.107.0.4/30" -PeerAsn 1234 -VlanId 200 -SharedKey "A1B2C3D4"
    

查看 Azure 公共对等互连详细信息To view Azure public peering details

若要查看配置详细信息,请使用以下 cmdlet:To view configuration details, use the following cmdlet:

Get-AzureBGPPeering -AccessType Public -ServiceKey "*********************************"

返回:Return:

AdvertisedPublicPrefixes       : 
AdvertisedPublicPrefixesState  : Configured
AzureAsn                       : 12076
CustomerAutonomousSystemNumber : 
PeerAsn                        : 1234
PrimaryAzurePort               : 
PrimaryPeerSubnet              : 131.107.0.0/30
RoutingRegistryName            : 
SecondaryAzurePort             : 
SecondaryPeerSubnet            : 131.107.0.4/30
State                          : Enabled
VlanId                         : 200

更新 Azure 公共对等互连配置To update Azure public peering configuration

可以使用以下 cmdlet 更新配置的任何部分。You can update any part of the configuration using the following cmdlet. 在此示例中,线路的 VLAN ID 将从 200 更新为 600。In this example, the VLAN ID of the circuit is being updated from 200 to 600.

Set-AzureBGPPeering -AccessType Public -ServiceKey "*********************************" -PrimaryPeerSubnet "131.107.0.0/30" -SecondaryPeerSubnet "131.107.0.4/30" -PeerAsn 1234 -VlanId 600 -SharedKey "A1B2C3D4"

确认线路显示为已预配并已启用。Verify that the circuit shows as Provisioned and Enabled.

删除 Azure 公共对等互连To delete Azure public peering

可以运行以下 cmdlet 来删除对等互连配置:You can remove your peering configuration by running the following cmdlet:

Remove-AzureBGPPeering -AccessType Public -ServiceKey "*********************************"

后续步骤Next steps

接下来,请将 VNet 链接到 ExpressRoute 线路Next, Link a VNet to an ExpressRoute circuit.