Share via


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

路由原則提供操作員允許或拒絕網路網狀架構中第 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-Prefix 類型的 ARM 資源。

清單中的前置詞會以遞增連續處理,而比對程式會在第一次比對之後停止。 如果第一個比對條件為「拒絕」,則會卸載路由,而且不會進一步傳播。 如果第一個比對條件為「允許」,則會中止進一步比對,並根據路由原則的動作部分處理路由。

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

IP 前置詞的參數

參數 描述 範例 必要
資源群組 特別針對您選擇的 IP 前置詞使用適當的資源組名 resourceGroupName True
resource-name IP 前置詞的資源名稱 ipprefixv4-1204-cn1 True
位置 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-Community 類型的 ARM 資源。 運算子會指定新增/移除路由的條件和動作,因為它們會傳播向上串流/向下串流,或以特定社群值標記路由。

IP 社群的參數

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

注意

wellKnownCommunities必須傳遞 或 communityMembers 參數,才能建立 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 資源。 ExtendedCommunityList 用於指定比對條件和路由原則的動作屬性。

IP 擴充社群的參數

參數 描述 範例 必要
資源群組 為您的 IP 首碼特別使用適當的資源組名 resourceGroupName True
resource-name ipPrefix 的資源名稱 ipprefixv4-1204-cn1 True
位置 AzON Azure 區域在 NFC 建立期間使用 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」 範圍內,以及 「0-4294967295」 範圍內的 「ASN(plain)」。 "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-Prefix 的資源名稱 ipprefixv4-1204-cn1 True
位置 AzON Azure 區域在 NFC 建立期間使用 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"
}