為 NNI 和第 3 層隔離網域外部網路建立存取控制清單 (ACL) 管理

存取控制清單 (ACL) 是一組規則,規範網路內的輸入和輸出封包流程。 Azure 的連接點網路網狀架構服務提供一種 API 型機制,為網路對網路互連和第 3 層隔離網域外部網路設定 ACL。 本指南概述建立 ACL 的步驟。

建立存取控制清單 (ACL)

若要建立 ACL 並定義其屬性,您可以使用 az networkfabric acl create 命令。 以下是涉及的步驟:

必要條件

  1. 設定訂用帳戶 (如有必要):

如果您有多個訂用帳戶,且需要將一個訂用帳戶設定為預設訂用帳戶,則可以使用下列命令這樣做:

az account set --subscription <subscription-id>
  1. 建立 ACL:
    az networkfabric acl create --resource-group "<resource-group>" --location "<location>" --resource-name "<acl-name>" --annotation "<annotation>" --configuration-type "<configuration-type>" --default-action "<default-action>" --match-configurations "[{matchConfigurationName:<match-config-name>,sequenceNumber:<sequence-number>,ipAddressType:<IPv4/IPv6>,matchConditions:[{ipCondition:{type:<SourceIP/DestinationIP>,prefixType:<Prefix/Exact>,ipPrefixValues:['<ip-prefix1>', '<ip-prefix2>', ...]}}],actions:[{type:<Action>}]}]"
參數 描述
資源群組 指定網路網狀架構的資源群組。
Location 定義建立 ACL 的位置。
資源名稱 提供 ACL 的名稱。
註釋 選擇性地新增 ACL 的描述或註釋。
組態類型 指定設定是內嵌還是透過使用檔案。
預設動作 定義找不到相符項目時要採取的預設動作。
比對設定 定義條件和動作進行流量比對。
動作 指定要根據比對條件採取的動作。

參數使用方式指引

下表提供有關建立 ACL 時使用參數的指引:

參數 描述 範例或範圍
defaultAction 定義要採取的預設動作 "defaultAction": "Permit"
資源群組 網路網狀架構的資源群組 nfresourcegroup
resource-name ACL 的名稱 example-ingressACL
vlanGroups VLAN 群組的清單
vlans 需要比對的 VLAN 清單
match-configurations 比對設定的名稱 example_acl
matchConditions 需要比對的條件
ttlValues TTL [存留時間] 0-255
dscpMarking 需要比對的 DSCP 標記 0-63
fargments 指定 IP 片段封包 範圍:1-8191
範例:[1, 5, 1250-1300, 8000-8191]
portCondition 需要比對的連接埠條件
portType 需要比對的連接埠類型 範例:SourcePort
連接埠 需要比對的連接埠號碼 範圍:0-65535
範例:[1, 10, 500, 1025-1050, 64000-65535]
protocolTypes 需要比對的通訊協定 [tcp, udp, range[1-2, 1, 2]]
vlanMatchCondition 需要比對的 VLAN 比對條件
layer4Protocol 第 4 層通訊協定 應該是 TCP 或 UDP
ipCondition 需要比對的 IP 條件
動作 要根據比對條件採取的動作 範例:允許
configuration-type 設定類型 (內嵌或檔案) 範例:內嵌

注意

  • 內嵌連接埠和內嵌 VLAN 是使用 azcli 靜態定義的。
  • PortGroupNames 和 VlanGroupNames 是動態定義的。
  • 不允許將內嵌連接埠與 portGroupNames 合併,同樣適用於內嵌 VLAN 和 VLANGroupNames。
  • IPGroupNames 與 IpPrefixValues 無法合併。
  • 輸出 ACL 不支援某些選項,例如 IP 選項、IP 長度、片段、乙太類型、DSCP 標記和 TTL 值。
  • 輸入 ACL 不支援下列選項:etherType。
  • 連接埠輸入可以是 port-numberrange-of-ports
  • 片段輸入可以是 port-numberrange-of-ports

用於 ACL 建立的範例承載

az networkfabric acl create --resource-group "example-rg" --location "eastus2euap" --resource-name "example-Ipv4ingressACL" --annotation "annotation" --configuration-type "Inline" --default-action "Deny" --match-configurations "[{matchConfigurationName:example-match,sequenceNumber:1110,ipAddressType:IPv4,matchConditions:[{ipCondition:{type:SourceIP,prefixType:Prefix,ipPrefixValues:['10.18.0.124/30','10.18.0.128/30','10.18.30.16/30','10.18.30.20/30']}},{ipCondition:{type:DestinationIP,prefixType:Prefix,ipPrefixValues:['10.18.0.124/30','10.18.0.128/30','10.18.30.16/30','10.18.30.20/30']}}],actions:[{type:Count}]}]"

範例輸出

{
  "administrativeState": "Disabled",
  "annotation": "annotation",
  "configurationState": "Succeeded",
  "configurationType": "Inline",
  "defaultAction": "Deny",
  "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Fab3LabNF-4-0/providers/Microsoft.ManagedNetworkFabric/accessControlLists/L3domain091123-Ipv4egressACL",
  "location": "eastus2euap",
  "matchConfigurations": [
    {
      "actions": [
        {
          "type": "Count"
        }
      ],
      "ipAddressType": "IPv4",
      "matchConditions": [
        {
          "ipCondition": {
            "ipPrefixValues": [
              "10.18.0.124/30",
              "10.18.0.128/30",
              "10.18.30.16/30",
              "10.18.30.20/30"
            ],
            "prefixType": "Prefix",
            "type": "SourceIP"
          }
        },
        {
          "ipCondition": {
            "ipPrefixValues": [
              "10.18.0.124/30",
              "10.18.0.128/30",
              "10.18.30.16/30",
              "10.18.30.20/30"
            ],
            "prefixType": "Prefix",
            "type": "DestinationIP"
          }
        }
      ],
      "matchConfigurationName": "example-Ipv4ingressACL ",
      "sequenceNumber": 1110
    }
  ],
  "name": "example-Ipv4ingressACL",
  "provisioningState": "Succeeded",
  "resourceGroup": "Fab3LabNF-4-0",
  "systemData": {
    "createdAt": "2023-09-11T10:20:20.2617941Z",
    "createdBy": "user@email.com",
    "createdByType": "User",
    "lastModifiedAt": "2023-09-11T10:20:20.2617941Z",
    "lastModifiedBy": "user@email.com",
    "lastModifiedByType": "User"
  },
  "type": "microsoft.managednetworkfabric/accesscontrollists"
}

注意

在建立 ACL 之後,請務必記下 ACL 參考識別碼以供進一步參考。

後續步驟

在 Azure 網狀架構中將存取控制清單 (ACL) 套用至 NNI