共用方式為


網路網狀架構中的路由原則

路由原則可讓運算子允許或拒絕關於網路網狀架構中第 3 層隔離網域的路由。

使用路由原則時,系統會在透過邊界閘道協定 (BGP) 散發路由時,透過社群值和擴充社群值為路由加上特定屬性標籤。 同樣地,在 BGP 接聽程式端也可以撰寫路由原則,以根據社群值和擴充社群值屬性來捨棄/允許路由。

路由原則可讓運算子控制透過 BGP 得知/散發的路由。 每個路由原則都會模型化為 Microsoft.managednetworkfabric 底下的個別最上層 Azure Resource Manager (ARM) 資源。 運算子可以建立、讀取和刪除路由原則資源。 運算子會建立路由原則 ARM 資源,然後在所需的強制執行點設定 L3 隔離網域中的識別碼。 路由原則只能套用在單一強制執行點上。 路由原則無法套用在多個強制執行點上。

在網路網狀架構中,系統可在第 3 層隔離網域的下列端點上強制執行路由原則:

外部網路 (選項 A 和選項 B):

針對輸出,將外部網路資源的 exportRoutePolicyId 屬性設定為針對輸出方向所建立的路由原則資源識別碼。 將外部網路資源的 importRoutePolicyId 屬性設定為針對輸入方向所建立的路由原則資源識別碼。

內部網路:

針對輸出,將內部網路資源的 exportRoutePolicyId 屬性設定為針對輸出方向所建立的路由原則資源識別碼。 將內部網路資源的 importRoutePolicyId 屬性設定為針對輸入方向所建立的路由原則資源識別碼。

跨所有內部網路的連線子網路:

針對輸出,將 L3 隔離網域的 connectedSubnetRoutePolicy 屬性設定為針對輸出方向所建立的路由原則資源識別碼。

路由原則的條件和動作

您可以指定下列條件組合:

  • IP 前置詞
  • IP 社群
  • 擴充社群清單

動作

當條件相符時,可以指定下列動作:

  • 捨棄路由
  • 允許路由並套用下列其中一個特定動作
  • 新增/移除指定的社群值和擴充社群值
  • 覆寫指定的社群值和擴充社群值

IP 首碼

IP 前置詞可用於指定路由原則的比對條件。 IP 前置詞資源可讓運算子根據 IP 前置詞 (IPv4 和 IPv6) 來操作路由。 IP 前置詞可讓運算子捨棄特定前置詞而不讓路由向上游/下游傳播,或者,讓運算子使用特定社群值或擴充社群值來標記路由。 運算子必須藉由提供具有序號和動作的前置詞清單,來建立類型為 IP 前置詞的 ARM 資源。

清單中的前置詞會以遞增順序來處理,比對程序則會在最初相符出現後停止。 如果最初相符條件為「拒絕」,則會捨棄路由,不會進一步傳播。 如果最初相符條件為「允許」,則會中止進一步的比對,並且會根據路由原則的動作部分來處理路由。

IP 前置詞只會指定路由原則的比對條件。 其不會指定路由原則的動作部分。

IP 前置詞的參數

參數 描述 範例 必要
資源群組 使用特別適用於所選 IP 前置詞的資源群組名稱 resourceGroupName True
resource-name IP 前置詞的資源名稱 ipprefixv4-1204-cn1 True
location 在建立 NFC 時所使用的 Azure 區域 eastus True
action 要針對前置詞採取的動作 - 允許 拒絕或允許 True
sequenceNumber 前置詞的處理順序。 系統會從最低序號開始評估前置詞清單,並在清單中往下繼續評估,直到有相符項目為止。 一旦找到相符項目,就會將允許或拒絕陳述式套用至該網路,並忽略清單的其餘部分 100 True
networkPrefix 指定要允許或拒絕 IPv4/IPv6 封包的網路前置詞。 1.1.1.0/24 True
條件 指定的前置詞清單界限 - EqualTo | GreaterThanOrEqualTo | LesserThanOrEqualTo EqualTo
subnetMaskLength SubnetMaskLength 會指定要相符的最小 networkPrefix 長度。 有指定條件時為必要項目。 32

建立 IP 前置詞

此命令會建立具有 IPv4 前置詞規則的 IP 前置詞資源:

az networkfabric ipprefix create \
--resource-group "ResourceGroupName" \
--resource-name "ipprefixv4-1204-cn1" \
--location "eastus" \
--ip-prefix-rules '[{"action": "Permit", "sequenceNumber": 10, "networkPrefix": "10.10.10.0/28", "condition": "EqualTo", "subnetMaskLength": 28}, {"action": "Permit", "sequenceNumber": 12, "networkPrefix": "20.20.20.0/24", "condition": "EqualTo", "subnetMaskLength": 24}]'

預期輸出:

{
  "annotation": null,
  "id": "/subscriptions/xxxx-xxxx/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv4-1204-cn1",
  "ipPrefixRules": [
    {
      "action": "Permit",
      "condition": "GreaterThanOrEqualTo",
      "networkPrefix": "10.10.10.0/28",
      "sequenceNumber": 10,
      "subnetMaskLength": 28
    }
  ],
  "location": "eastus",
  "name": " ipprefixv4-1204-cn1",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "systemData": {
    "createdAt": "2023-XX-XXT09:34:19.095543+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:34:19.095543+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipprefixes"
}

此命令會建立具有 IPv6 前置詞規則的 IP 前置詞資源,

az networkfabric ipprefix create \
--resource-group "ResourceGroupName" \
--resource-name "ipprefixv6-2701-cn1" \
--location "eastus" \
--ip-prefix-rules '[{"action": "Permit", "sequenceNumber": 10, "networkPrefix": "fda0:d59c:da12:20::/64", "condition": "GreaterThanOrEqualTo", "subnetMaskLength": 68}]'

預期輸出

{
  "annotation": null,
  "id": "/subscriptions/xxxx-xxxx/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-cn1",
  "ipPrefixRules": [
    {
      "action": "Permit",
      "condition": "GreaterThanOrEqualTo",
      "networkPrefix": "fda0:d59c:da12:20::/64",
      "sequenceNumber": 10,
      "subnetMaskLength": 68
    }
  ],
  "location": "eastus",
  "name": "ipprefixv6-2701-cn1",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "systemData": {
    "createdAt": "2023-XX-XXT09:34:19.095543+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:34:19.095543+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipprefixes"
}

IP 社群

IP 社群資源可讓運算子根據標記為路由的社群值來操作路由。 此社群資源可讓運算子指定條件和動作以在路由向上游/下游傳播時新增/移除路由,或者,讓運算子使用特定社群值來標記路由。 運算子必須建立類型為 IP 社群的 ARM 資源。 運算子會指定條件和動作以在路由向上游/下游傳播時新增/移除路由,或者,讓運算子使用特定社群值來標記路由。

IP 社群的參數

參數 描述 範例 必要
資源群組 使用特別適用於您 IP 前置詞的資源群組名稱 resourceGroupName True
resource-name IP 前置詞的資源名稱 ipprefixv4-1204-cn1 True
location 在建立 NFC 時所使用的 AzON Azure 區域 eastus True
action 要針對 IP 社群採取的動作 - 允許 拒絕或允許 True
wellKnownCommunities 支援的已知社群清單。Internet - 向網際網路社群公告路由。 LocalAS - 只向 localAS 對等項目公告路由。 NoAdvertise - 不向任何對等項目公告路由。 NoExport - 不要匯出至下一個 AS。 GShut - 正常關機 (GSHUT) 在終止 BGP 連線之前撤銷路由 LocalAS True
communityMembers 列出 IP 社群的 communityMembers。 預期的格式為「AA:nn >> 範例「65535:65535」,<integer32>>> 範例 4294967040。 「AA:nn」的可能值為 0-65535,<integer32> 的可能值為 1-4294967040。 65535:65535 True

注意

必須傳遞 wellKnownCommunitiescommunityMembers 參數才能建立 IP 社群資源。

建立 IP 社群

此命令會建立 IP 社群資源:

az networkfabric ipcommunity create \
--resource-group "ResourceGroupName" \
--resource-name "ipcommunity-2701" \
--location "eastus" \
--action "Permit" \
--well-known-communities "Internet" "LocalAS" "GShut" \
--community-members "65500:12701"

預期輸出:

{
  "action": "Permit",
  "annotation": null,
  "communityMembers": [
    "65500:12701"
  ],
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-2701",
  "location": "eastus",
  "name": "ipcommunity-2701",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "systemData": {
    "createdAt": "2023-XX-XXT09:48:15.472935+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:48:15.472935+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipcommunities",
  "wellKnownCommunities": [
    "Internet",
    "LocalAS",
    "GShut"
  ]
}

顯示 IP 社群

此命令會顯示 IP 社群資源:

az networkfabric ipcommunity show --resource-group "ResourceGroupName" --resource-name "ipcommunity-2701"

預期輸出:

{
  "action": "Permit",
  "annotation": null,
  "communityMembers": [
    "65500:12701"
  ],
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-2701",
  "location": "eastus",
  "name": "ipcommunity-2701",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "systemData": {
    "createdAt": "2023-XX-XXT09:48:15.472935+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:48:15.472935+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipcommunities",
  "wellKnownCommunities": [
    "Internet",
    "LocalAS",
    "GShut"
  ]
}

IP 擴充社群

IPExtendedCommunity 資源可讓運算子根據路由目標來操作路由。 運算子會使用此項目來指定條件和動作以在路由向上游/下游傳播時新增/移除路由,或者,讓運算子使用特定擴充社群值來標記路由。 運算子必須藉由提供社群值和特定屬性的清單,來建立類型為 IPExtendedCommunityList 的 ARM 資源。 ExtendedCommunityLists 可用於指定路由原則的比對條件和動作屬性。

IP 擴充社群的參數

參數 描述 範例 必要
資源群組 使用特別適用於您 IP 前置詞的資源群組名稱 resourceGroupName True
resource-name ipPrefix 的資源名稱 ipprefixv4-1204-cn1 True
location 在建立 NFC 時所使用的 AzON Azure 區域 eastus True
action 要針對 IP 擴充社群採取的動作 - 允許 拒絕或允許 True
routeTargets 路由目標清單。 預期格式為「ASN(plain):nn」>> 範例「4294967294:50」,「ASN.ASN:nn」>> 範例「65533.65333:40」,「IP-address:nn」>> 範例「10.10.10.10:65535」。 「nn」的可能值在「0-65535」範圍內,「ASN(plain)」的可能值在「0-4294967295」範圍內。 「1234:5678」 True

建立 IP 擴充社群

此命令會建立 IP 擴充社群資源:

az networkfabric ipextendedcommunity create \
--resource-group "ResourceGroupName" \
--resource-name "ipextcommunity-2701" \
--location "eastus"  \
--action "Permit" \
--route-targets "65046:45678"

預期輸出:

{
  "action": "Permit",
  "annotation": null,
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/ipextcommunity-2701",
  "location": "eastus",
  "name": "ipextcommunity-2701",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "routeTargets": [
    "65046:45678"
  ],
  "systemData": {
    "createdAt": "2023-XX-XXT09:52:30.385929+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:52:30.385929+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipextendedcommunities"
}

顯示 IP 擴充社群

此指令會顯示 IP 擴充社群資源:

az networkfabric ipextendedcommunity show --resource-group "ResourceGroupName" --resource-name "ipextcommunity-2701"

預期輸出:

{
  "action": "Permit",
  "annotation": null,
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/ipextcommunity-2701",
  "location": "eastus",
  "name": "ipextcommunity-2701",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "routeTargets": [
    "65046:45678"
  ],
  "systemData": {
    "createdAt": "2023-XX-XXT09:52:30.385929+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT09:52:30.385929+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/ipextendedcommunities"
}

路由原則

路由原則資源可讓運算子根據 IP 前置詞、IP 社群清單和 IP 擴充社群清單來指定條件和動作。 每個路由原則都包含多個陳述式。 每個陳述式都包含序號、條件和動作。 條件可以是 IP 前置詞、IP 社群和 IP 擴充社群的組合,並以序號的遞增順序套用。 系統會執行與第一個相符條件對應的動作。 如果相符的條件以拒絕作為動作,則會捨棄路由,不會進一步處理。 如果與相符條件對應的路由原則中的動作為「允許」,則會允許下列動作組合:

  • 更新本機喜好設定
  • IpCommunityLists 的新增/刪除或設定
  • IpExtendedCommunityLists 的新增/刪除或設定

路由原則的參數

參數 描述 範例 必要
資源群組 使用特別適用於您 IP 前置詞的資源群組名稱 resourceGroupName True
resource-name IP 前置詞的資源名稱 ipprefixv4-1204-cn1 True
location 在建立 NFC 時所使用的 AzON Azure 區域 eastus True
陳述式 一或多個路由原則陳述式的清單 True
sequenceNumber 路由原則陳述式的處理順序。 系統會從最低序號開始評估陳述式,並在清單中往下繼續評估,直到有相符的比對條件為止。 一旦找到相符項目,就會套用動作並忽略清單的其餘部分 1 True
條件 路由原則條件屬性。 其中包含 IP 社群 ARM 識別碼或 ipExtendedCommmunicty ARM 識別碼或 ipPrefix ARM 識別碼的清單。 條件中需要 ipCommunityIds、ipCommunityIds、ipPrefixId 這三個項目的其中一個。 如果指定了多個,且其中任何一個資源有相符項目,則條件便相符。 1234:5678 True
ipCommunityIds IP 社群資源識別碼的清單 False
ipExtendedCommunityIds IPExtendedCommunity 資源識別碼的清單 False
ipPrefixId IpPrefix 的 Arm 資源識別碼 False
action 路由原則動作屬性。 此屬性描述陳述式中有相符的條件時所要執行的動作。 至少必須啟用 localPreference、ipCommunityProperties 或 ipExtendedCommunityProperties 的其中一個 執照 True
localPreference 要設定為動作一部分的本機喜好設定 10 False
ipCommunityProperties 需要新增、移除或設定為動作一部分的 IP 社群詳細資料 False
add 當動作是新增 IP 社群或 IP 擴充社群時適用
delete 當動作是刪除 IP 社群或 IP 擴充社群時適用
set 當動作是設定 IP 社群或 IP 擴充社群時適用
ipCommunityIds 需要新增、刪除或設定的 IP 社群 ARM 資源識別碼
ipExtendedCommunityProperties 需要新增、移除或設定為動作一部分的 IP 擴充社群詳細資料
ipExtendedCommunityIDs 需要新增、刪除或設定的 IP 擴充社群 ARM 資源識別碼

建立路由原則

此命令會建立路由原則:

az networkfabric routepolicy create \
--resource-group "ResourceGroupName"  \
--resource-name "rcf-Fab3-l3domain-v6-connsubnet-ext-policy" \
--location "eastus" \
--statements '[ \{"sequenceNumber": 10, "condition":{"ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-staticsubnet"}, \
 "action": {"actionType": "Permit", "ipCommunityProperties": {"set": \
   {"ipCommunityIds": ["/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-2701-staticsubnet"]}}}}, \
 {"sequenceNumber": 30, "condition":{"ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-connsubnet"},  \
 "action": {"actionType": "Permit", "ipCommunityProperties": {"set":  \
 {"ipCommunityIds": ["/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-connsubnet-2701"]}}}},\
]' 

預期輸出:

{
  "annotation": null,
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/routePolicies/rcf-Fab3-l3domain-v6-connsubnet-ext-policy",
  "location": "eastus",
  "name": "rcf-Fab3-l3domain-v6-connsubnet-ext-policy",
  "provisioningState": "Accepted",
  "resourceGroup": "ResourceGroupName",
  "statements": [
    {
      "action": {
        "actionType": "Permit",
        "ipCommunityProperties": {
          "add": null,
          "delete": null,
          "set": {
            "ipCommunityIds": [
              "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-2701-staticsubnet"
            ]
          }
        },
        "ipExtendedCommunityProperties": null,
        "localPreference": null
      },
      "annotation": null,
      "condition": {
        "ipCommunityIds": null,
        "ipExtendedCommunityIds": null,
        "ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-staticsubnet"
      },
      "sequenceNumber": 10
    },
    {
      "action": {
        "actionType": "Permit",
        "ipCommunityProperties": {
          "add": null,
          "delete": null,
          "set": {
            "ipCommunityIds": [
              "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-connsubnet-2701"
            ]
          }
        },
        "ipExtendedCommunityProperties": null,
        "localPreference": null
      },
      "annotation": null,
      "condition": {
        "ipCommunityIds": null,
        "ipExtendedCommunityIds": null,
        "ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-connsubnet"
      },
      "sequenceNumber": 30
    }
  ],
  "systemData": {
    "createdAt": "2023-XX-XXT10:10:21.123560+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT10:10:21.123560+00:00",
    "lastModifiedBy": "user@address.com",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/routepolicies"
} 

顯示路由原則

此命令會顯示路由原則:

az networkfabric routepolicy show --resource-group "ResourceGroupName" --resource-name "rcf-Fab3-l3domain-v6-connsubnet-ext-policy"

預期輸出:

{
  "annotation": null,
  "id": "/subscriptions/9531faa8-8c39-4165-b033-48697fe943db/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/routePolicies/rcf-Fab3-l3domain-v6-connsubnet-ext-policy",
  "location": "eastus",
  "name": "rcf-Fab3-l3domain-v6-connsubnet-ext-policy",
  "provisioningState": "Succeeded",
  "resourceGroup": "ResourceGroupName",
  "statements": [
    {
      "action": {
        "actionType": "Permit",
        "ipCommunityProperties": {
          "add": null,
          "delete": null,
          "set": {
            "ipCommunityIds": [
              "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-2701-staticsubnet"
            ]
          }
        },
        "ipExtendedCommunityProperties": null,
        "localPreference": null
      },
      "annotation": null,
      "condition": {
        "ipCommunityIds": null,
        "ipExtendedCommunityIds": null,
        "ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-staticsubnet"
      },
      "sequenceNumber": 10
    },
    {
      "action": {
        "actionType": "Permit",
        "ipCommunityProperties": {
          "add": null,
          "delete": null,
          "set": {
            "ipCommunityIds": [
              "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipCommunities/ipcommunity-connsubnet-2701"
            ]
          }
        },
        "ipExtendedCommunityProperties": null,
        "localPreference": null
      },
      "annotation": null,
      "condition": {
        "ipCommunityIds": null,
        "ipExtendedCommunityIds": null,
        "ipPrefixId": "/subscriptions/<subscription-id>/resourceGroups/ResourceGroupName/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/ipprefixv6-2701-connsubnet"
      },
      "sequenceNumber": 30
    }
  ],
  "systemData": {
    "createdAt": "2023-XX-XXT10:10:21.123560+00:00",
    "createdBy": "user@address.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-XX-XXT10:10:21.123560+00:00",
    "lastModifiedBy": "user@addresscom",
    "lastModifiedByType": "User"
  },
  "tags": null,
  "type": "microsoft.managednetworkfabric/routepolicies"
}