本文介绍如何使用 PowerShell 启用和禁用 ExpressRoute 线路的对等互连。 默认情况下,对等互连在创建时处于启用状态。 禁用对等互连后,ExpressRoute 线路的主连接和辅助连接上的 BGP 会话将断开连接。 你将失去此对等互连与 Microsoft 之间的连接。 启用对等互连后,ExpressRoute 线路的主连接和辅助连接上的 BGP 会话将建立。 为了进行对等连接,将重新连接到 Azure。 可在 ExpressRoute 线路上单独为 Microsoft 对等互连和 Azure 专用对等互连启用和禁用对等互连。
在两种情况下,你可能会发现重置 ExpressRoute 对等互连很有帮助。
- 如果您想测试您的灾难恢复方案的设计和实施。 例如,你有两条 ExpressRoute 线路。 可以在一条线路上禁用对等互连,并强制网络流量故障转移到另一条线路。
- 在您的 ExpressRoute 电路的 Azure 专用对等互连或 Microsoft 对等互连上启用双向转发检测 (BFD)。 如果在2018年8月1日之后创建ExpressRoute线路,并且在2020年1月10日之后创建Microsoft对等连接,则默认在Azure专用对等连接上启用BFD。 如果你的线路是在所列日期之前创建的,则需要重置对等互连以启用 BFD。
使用 Azure PowerShell
本文中的步骤和示例使用 Azure PowerShell Az 模块。 若要在计算机上本地安装 Az 模块,请参阅安装 Azure PowerShell。 若要详细了解新 Az 模块,请参阅新 Azure Powershell Az 模块简介。 PowerShell 命令行小程序会频繁更新。 如果未运行最新版本,在说明中指定的值可能无法使用。 若要在系统上查找已安装的 PowerShell 版本,请使用 Get-Module -ListAvailable Az cmdlet。
重置网络对等互联
如果在本地运行 PowerShell,请使用提升的权限打开 PowerShell 控制台,然后连接到帐户。 使用下面的示例来帮助你进行连接:
Connect-AzAccount -Environment AzureChinaCloud如果有多个 Azure 订阅,请查看该帐户的订阅。
Get-AzSubscription指定要使用的订阅。
Select-AzSubscription -SubscriptionName "Replace_with_your_subscription_name"运行以下命令以获取 ExpressRoute 电路。
$ckt = Get-AzExpressRouteCircuit -Name "ExpressRouteARMCircuit" -ResourceGroupName "ExpressRouteResourceGroup"识别要禁用或启用的对等连接。 Peerings是一个数组。 在以下示例中,Peerings[0] 是 Azure 私有对等连接,而 Peerings[1] 是 Microsoft 对等连接。
Name : ExpressRouteARMCircuit ResourceGroupName : ExpressRouteResourceGroup Location : chinanorth Id : /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/ExpressRouteARMCircuit Etag : W/"aaaa0000-bb11-2222-33cc-444444dddddd" ProvisioningState : Succeeded Sku : { "Name": "Standard_MeteredData", "Tier": "Standard", "Family": "MeteredData" } CircuitProvisioningState : Enabled ServiceProviderProvisioningState : Provisioned ServiceProviderNotes : ServiceProviderProperties : { "ServiceProviderName": "Beijing Telecom Ethernet", "PeeringLocation": "Beijing", "BandwidthInMbps": 50 } ServiceKey : aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e Peerings : [ { "Name": "AzurePrivatePeering", "Etag": "W/\"aaaa0000-bb11-2222-33cc-444444dddddd\"", "Id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/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/\"aaaa0000-bb11-2222-33cc-444444dddddd\"", "Id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/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 :运行以下命令,将对等互连状态更改为“禁用”。
$ckt.Peerings[0].State = "Disabled" Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt对等互连应该处于您设定的禁用状态。
运行以下命令,将对等互连状态更改回“启用”。
$ckt.Peerings[0].State = "Enabled" Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt对等互连应处于你设置的已启用状态。
后续步骤
如果需要帮助排查 ExpressRoute 问题,请参阅以下文章: