Share via


使用 Azure CLI 設定路由喜好設定以影響路由選取

了解如何在 Azure 路由伺服器中使用路由喜好設定,以影響其路由學習和選取。 如需詳細資訊,請參閱路由喜好設定 (預覽)

重要

路由喜好設定目前為預覽狀態。 請參閱 Microsoft Azure 預覽版增補使用規定,以了解適用於 Azure 功能 (搶鮮版 (Beta)、預覽版,或尚未正式發行的版本) 的法律條款。

必要條件

檢視路由喜好設定

使用 az network routeserver show 來檢視目前的路由伺服器設定,包括其路由喜好設定。

# Show the Route Server configuration.
az network routeserver show --resource-group 'myResourceGroup' --name 'myRouteServer'

在輸出中,您可以在 "hubRoutingPreference" 前看到目前的路由喜好設定:

{
  "allowBranchToBranchTraffic": false,
  "etag": "W/\"00000000-1111-2222-3333-444444444444\"",
  "hubRoutingPreference": "ExpressRoute",
  "id": "/subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualHubs/myRouteServer",
  "kind": "RouteServer",
  "location": "eastus",
  "name": "myRouteServer",
  "provisioningState": "Succeeded",
  "resourceGroup": "myResourceGroup",
  "routeTable": {
    "routes": []
  },
  "routingState": "Provisioned",
  "sku": "Standard",
  "tags": {},
  "type": "Microsoft.Network/virtualHubs",
  "virtualHubRouteTableV2s": [],
  "virtualRouterAsn": 65515,
  "virtualRouterAutoScaleConfiguration": {
    "minCapacity": 2
  },
  "virtualRouterIps": [
    "10.1.1.5",
    "10.1.1.4"
  ]
}

注意

預設路由喜好設定為 [ExpressRoute]

設定路由喜好設定

使用 az network routeserver update 來更新路由喜好設定。

# Change the routing preference to AS Path.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'ASPath' --resource-group 'myResourceGroup'
# Change the routing preference to VPN Gateway.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'VpnGateway' --resource-group 'myResourceGroup'
# Change the routing preference to ExpressRoute.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'ExpressRoute' --resource-group 'myResourceGroup'