重置 ExpressRoute 线路对等互连Reset ExpressRoute circuit peerings

本文介绍如何使用 PowerShell 禁用和启用 ExpressRoute 线路的对等互连。This article describes how to disable and enable peerings of an ExpressRoute circuit using PowerShell. 禁用对等互连后,ExpressRoute 线路的主连接和辅助连接上的 BGP 会话都将关闭。When you disable a peering, the BGP session on both the primary connection and the secondary connection of your ExpressRoute circuit will be shut down. 你将无法通过此对等互连连接到 Microsoft。You will lose connectivity through this peering to Microsoft. 启用对等互连后,ExpressRoute 线路的主连接和辅助连接上的 BGP 会话都将启动。When you enable a peering, the BGP session on both the primary connection and the secondary connection of your ExpressRoute circuit will be brought up. 你将能够通过此对等互连再次连接到 Microsoft。You will regain connectivity through this peering to Microsoft. 可单独对 ExpressRoute 线路启用和禁用 Microsoft 对等互连和 Azure 专用对等互连。You can enable and disable Microsoft Peering and Azure Private Peering on an ExpressRoute circuit independently. 在 ExpressRoute 线路上初次配置对等互连时,将默认启用对等互连。When you first configure the peerings on your ExpressRoute circuit, the peerings are enabled by default.

存在几个有助于重置 ExpressRoute 对等互连的方案。There are a couple scenarios where you may find it helpful resetting your ExpressRoute peerings.

  • 测试灾难恢复设计和实现。Test your disaster recovery design and implementation. 例如,你有两条 ExpressRoute 线路。For example, you have two ExpressRoute circuits. 可以禁用一条线路的对等互连,并强制网络流量故障转移到另一条线路。You can disable the peerings of one circuit and force your network traffic to fail over to the other circuit.
  • 对 ExpressRoute 线路的 Azure 专用对等互连启用双向转发检测 (BFD)。Enable Bidirectional Forwarding Detection (BFD) on Azure Private Peering of your ExpressRoute circuit. 如果 ExpressRoute 线路在 2018 年 8 月 1 日之后创建,将默认启用 BFD。BFD is enabled by default if your ExpressRoute circuit is created after August 1, 2018. 如果线路在此之前创建,则未启用 BFD。If your circuit was created before that, BFD wasn't enabled. 可以通过禁用对等互连并重新启用它来启用 BFD。You can enable BFD by disabling the peering and reenabling it. 应注意,BFD 仅在 Azure 专用对等互连上受支持。It should be noted that BFD is supported on Azure Private Peering only.

使用 Azure PowerShellWorking with Azure PowerShell

本文中的步骤和示例使用 Azure PowerShell Az 模块。The steps and examples in this article use Azure PowerShell Az modules. 若要在计算机上本地安装 Az 模块,请参阅安装 Azure PowerShellTo install the Az modules locally on your computer, see Install Azure PowerShell. 若要详细了解新 Az 模块,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module, see Introducing the new Azure PowerShell Az module. PowerShell cmdlet 经常更新。PowerShell cmdlets are updated frequently. 如果未运行最新版本,在说明中指定的值可能无法使用。If you are not running the latest version, the values specified in the instructions may fail. 若要在系统上查找已安装的 PowerShell 版本,请使用 Get-Module -ListAvailable Az cmdlet。To find the installed versions of PowerShell on your system, use the Get-Module -ListAvailable Az cmdlet.

重置对等互连Reset a peering

  1. 如果在本地运行 PowerShell,请使用提升的权限打开 PowerShell 控制台,然后连接到帐户。If you are running PowerShell locally, open your PowerShell console with elevated privileges, and connect to your account. 使用下面的示例来帮助连接:Use the following example to help you connect:

    Connect-AzAccount -Environment AzureChinaCloud
    
  2. 如果有多个 Azure 订阅,请查看该帐户的订阅。If you have multiple Azure subscriptions, check the subscriptions for the account.

    Get-AzSubscription
    
  3. 指定要使用的订阅。Specify the subscription that you want to use.

    Select-AzSubscription -SubscriptionName "Replace_with_your_subscription_name"
    
  4. 运行以下命令,检索 ExpressRoute 线路。Run the following commands to retrieve your ExpressRoute circuit.

    $ckt = Get-AzExpressRouteCircuit -Name "ExpressRouteARMCircuit" -ResourceGroupName "ExpressRouteResourceGroup"
    
  5. 标识要禁用或启用的对等互连。Identify the peering you want to disable or enable. 对等互连是一个数组 。Peerings is an array. 在以下示例中,Peerings[0] 是 Azure 专用对等互连,而 Peerings[1] 是 Microsoft 对等互连。In the following example, Peerings[0] is Azure Private Peering and Peerings[1] Microsoft Peering.

    Name                             : ExpressRouteARMCircuit
    ResourceGroupName                : ExpressRouteResourceGroup
    Location                         : chinanorth
    Id                               : /subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit
    Etag                             : W/"cd011bef-dc79-49eb-b4c6-81fb6ea5d178"
    ProvisioningState                : Succeeded
    Sku                              : {
                                      "Name": "Standard_MeteredData",
                                      "Tier": "Standard",
                                      "Family": "MeteredData"
                                    }
    CircuitProvisioningState         : Enabled
    ServiceProviderProvisioningState : Provisioned
    ServiceProviderNotes             :
    ServiceProviderProperties        : {
                                      "ServiceProviderName": "Coresite",
                                      "PeeringLocation": "Los Angeles",
                                      "BandwidthInMbps": 50
                                    }
    ServiceKey                       : ########-####-####-####-############
    Peerings                         : [
                                      {
                                        "Name": "AzurePrivatePeering",
                                        "Etag": "W/\"cd011bef-dc79-49eb-b4c6-81fb6ea5d178\"",
                                        "Id": "/subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit/peerings/AzurePrivatePeering",
                                        "PeeringType": "AzurePrivatePeering",
                                        "State": "Enabled",
                                        "AzureASN": 12076,
                                        "PeerASN": 123,
                                        "PrimaryPeerAddressPrefix": "10.0.0.0/30",
                                        "SecondaryPeerAddressPrefix": "10.0.0.4/30",
                                        "PrimaryAzurePort": "",
                                        "SecondaryAzurePort": "",
                                        "VlanId": 789,
                                        "MicrosoftPeeringConfig": {
                                          "AdvertisedPublicPrefixes": [],
                                          "AdvertisedCommunities": [],
                                          "AdvertisedPublicPrefixesState": "NotConfigured",
                                          "CustomerASN": 0,
                                          "LegacyMode": 0,
                                          "RoutingRegistryName": "NONE"
                                        },
                                        "ProvisioningState": "Succeeded",
                                        "GatewayManagerEtag": "",
                                        "LastModifiedBy": "Customer",
                                        "Connections": []
                                      },
                                      {
                                        "Name": "MicrosoftPeering",
                                        "Etag": "W/\"cd011bef-dc79-49eb-b4c6-81fb6ea5d178\"",
                                        "Id": "/subscriptions/########-####-####-####-############/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit/peerings/MicrosoftPeering",
                                        "PeeringType": "MicrosoftPeering",
                                        "State": "Enabled",
                                        "AzureASN": 12076,
                                        "PeerASN": 123,
                                        "PrimaryPeerAddressPrefix": "3.0.0.0/30",
                                        "SecondaryPeerAddressPrefix": "3.0.0.4/30",
                                        "PrimaryAzurePort": "",
                                        "SecondaryAzurePort": "",
                                        "VlanId": 345,
                                        "MicrosoftPeeringConfig": {
                                          "AdvertisedPublicPrefixes": [
                                            "3.0.0.3/32"
                                          ],
                                          "AdvertisedCommunities": [],
                                          "AdvertisedPublicPrefixesState": "ValidationNeeded",
                                          "CustomerASN": 0,
                                          "LegacyMode": 0,
                                          "RoutingRegistryName": "NONE"
                                        },
                                        "ProvisioningState": "Succeeded",
                                        "GatewayManagerEtag": "",
                                        "LastModifiedBy": "Customer",
                                        "Connections": []
                                      }
                                    ]
    Authorizations                   : []
    AllowClassicOperations           : False
    GatewayManagerEtag               :
    
  6. 运行以下命令以更改对等互连状态。Run the following commands to change the state of the peering.

    $ckt.Peerings[0].State = "Disabled"
    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt
    

    对等互连应处于设定的某种状态。The peering should be in a state you set.

后续步骤Next steps

如果需要帮助排查 ExpressRoute 问题,请查看以下文章:If you need help to troubleshoot an ExpressRoute problem, check out the following articles: