Share via


在 Azure 操作員 Nexus 中的 NNI 上建立 ACL

在 Azure 操作員 Nexus 中,網路對網路互連 (NNI) PermitDeny 層級的 訪問控制清單和動作有助於保護管理虛擬專用網 (VPN) 上的安全殼層 (SSH) 存取。 您會在建立 NNI 資源之前建立輸入和輸出 ACL,然後在 NNI 承載中參考這些 ACL。 您必須先建立參考的輸入和輸出 ACL,才能佈建網路網狀架構。

以下是在 NNI 上建立 ACL 的高階步驟:

  1. 建立 NNI 輸入和輸出 ACL。
  2. 更新管理 NNI 中的 Azure Resource Manager 資源參考。
  3. 建立 NNI 並布建網路網狀架構。

參數使用指引

參數 描述 範例或範圍
defaultAction 要採取的默認動作。 如果您未定義流量,則允許流量。 "defaultAction": "Permit"
resource-group 網路網狀架構的資源群組。 nfresourcegroup
resource-name ACL 的名稱。 example-ingressACL
vlanGroups 虛擬局域網路 (VLAN) 群組的清單。
vlans 需要比對的 VLAN 清單。
match-configurations 比對組態的名稱。 example_acl. 不支援空白與連字元 (&&) 。
matchConditions 必須比對的條件。
ttlValues 存留時間(TTL)。 0-255
dscpMarking 需要比對的辨別服務代碼點 (DSCP) 標記。 0-63
portCondition 需要比對的埠條件。
portType 需要比對的埠類型。 範例:SourcePort。 允許的值: DestinationPortSourcePort
protocolTypes 需要比對的通訊協定。 [tcp, udp, range[1-2, 1, 2]]. 如果是通訊協定編號,則應該在的範圍 1-255中。
vlanMatchCondition 需要比對的 VLAN 比對條件。
layer4Protocol 第 4 層通訊協定。 應該是 TCPUDP
ipCondition 需要比對的IP條件。
actions 要根據比對條件採取的動作。 範例:permit
configuration-type 組態類型,可以是內嵌或檔案。 目前,Azure 操作員 Nexus 僅支援內嵌。 範例:inline

您也應該注意這些限制:

  • 內嵌埠和內嵌 VLAN 是使用 azcli來定義埠或 VLAN 的靜態方式。
  • portGroupNamesvlanGroupNames 是定義埠和 VLAN 的動態方式。
  • 不允許內嵌埠和 portGroupNames 一起。
  • 不允許內嵌 VLAN 和 vlanGroupNames 一起。
  • ipGroupNames 不允許和 ipPrefixValues 在一起。
  • 輸出 ACL 不支援 IP 選項、IP 長度、片段、EtherType、DSCP 標記或 TTL 值。
  • 輸入 ACL 不支援 EtherType 選項。

建立輸入 ACL

若要建立輸入 ACL,您可以使用下列 Azure CLI 命令。 此命令會建立具有指定組態的輸入 ACL,並提供預期的結果作為輸出。 視您的使用案例需要調整參數。

az networkfabric acl create
--resource-group "example-rg"
--location "eastus2euap"
--resource-name "example-Ipv4ingressACL"
--configuration-type "Inline"
--default-action "Permit"
--dynamic-match-configurations "[{ipGroups:[{name:'example-ipGroup',ipAddressType:IPv4,ipPrefixes:['10.20.3.1/20']}],vlanGroups:[{name:'example-vlanGroup',vlans:['20-30']}],portGroups:[{name:'example-portGroup',ports:['100-200']}]}]"
--match-configurations "[{matchConfigurationName:'example-match',sequenceNumber:123,ipAddressType:IPv4,matchConditions:[{etherTypes:['0x1'],fragments:['0xff00-0xffff'],ipLengths:['4094-9214'],ttlValues:[23],dscpMarkings:[32],portCondition:{flags:[established],portType:SourcePort,layer4Protocol:TCP,ports:['1-20']},protocolTypes:[TCP],vlanMatchCondition:{vlans:['20-30'],innerVlans:[30]},ipCondition:{type:SourceIP,prefixType:Prefix,ipPrefixValues:['10.20.20.20/12']}}],actions:[{type:Count,counterName:'example-counter'}]}]"

預期的輸出

{
    "properties": {
        "lastSyncedTime": "2023-06-17T08:56:23.203Z",
        "configurationState": "Succeeded",
        "provisioningState": "Accepted",
        "administrativeState": "Enabled",
        "annotation": "annotation",
        "configurationType": "File",
        "aclsUrl": "https://ACL-Storage-URL",
        "matchConfigurations": [{
            "matchConfigurationName": "example-match",
            "sequenceNumber": 123,
            "ipAddressType": "IPv4",
            "matchConditions": [{
                "etherTypes": ["0x1"],
                "fragments": ["0xff00-0xffff"],
                "ipLengths": ["4094-9214"],
                "ttlValues": [23],
                "dscpMarkings": [32],
                "portCondition": {
                    "flags": ["established"],
                    "portType": "SourcePort",
                    "l4Protocol": "TCP",
                    "ports": ["1-20"],
                    "portGroupNames": ["example-portGroup"]
                },
                "protocolTypes": ["TCP"],
                "vlanMatchCondition": {
                    "vlans": ["20-30"],
                    "innerVlans": [30],
                    "vlanGroupNames": ["example-vlanGroup"]
                },
                "ipCondition": {
                    "type": "SourceIP",
                    "prefixType": "Prefix",
                    "ipPrefixValues": ["10.20.20.20/12"],
                    "ipGroupNames": ["example-ipGroup"]
                }
            }]
        }],
        "actions": [{
            "type": "Count",
            "counterName": "example-counter"
        }]
    },
    "tags": {
        "keyID": "KeyValue"
    },
    "location": "eastUs",
    "id": "/subscriptions/xxxxxx/resourceGroups/resourcegroupname/providers/Microsoft.ManagedNetworkFabric/accessControlLists/acl",
    "name": "example-Ipv4ingressACL",
    "type": "microsoft.managednetworkfabric/accessControlLists",
    "systemData": {
        "createdBy": "email@address.com",
        "createdByType": "User",
        "createdAt": "2023-06-09T04:51:41.251Z",
        "lastModifiedBy": "UserId",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2023-06-09T04:51:41.251Z"
    }
}

建立輸出 ACL

若要建立輸出 ACL,您可以使用下列 Azure CLI 命令。 此命令會建立具有指定組態的輸出 ACL,並提供預期的結果作為輸出。 視您的使用案例需要調整參數。

az networkfabric acl create
--resource-group "example-rg"
--location "eastus2euap"
--resource-name "example-Ipv4egressACL"
--configuration-type "File"
--acls-url "https://ACL-Storage-URL"
--default-action "Permit"
--dynamic-match-configurations "[{ipGroups:[{name:'example-ipGroup',ipAddressType:IPv4,ipPrefixes:['10.20.3.1/20']}],vlanGroups:[{name:'example-vlanGroup',vlans:['20-30']}],portGroups:[{name:'example-portGroup',ports:['100-200']}]}]"

預期的輸出

{
    "properties": {
        "lastSyncedTime": "2023-06-17T08:56:23.203Z",
        "configurationState": "Succeeded",
        "provisioningState": "Accepted",
        "administrativeState": "Enabled",
        "annotation": "annotation",
        "configurationType": "File",
        "aclsUrl": "https://ACL-Storage-URL",
        "dynamicMatchConfigurations": [{
            "ipGroups": [{
                "name": "example-ipGroup",
                "ipAddressType": "IPv4",
                "ipPrefixes": ["10.20.3.1/20"]
            }],
            "vlanGroups": [{
                "name": "example-vlanGroup",
                "vlans": ["20-30"]
            }],
            "portGroups": [{
                "name": "example-portGroup",
                "ports": ["100-200"]
            }]
        }]
    },
    "tags": {
        "keyID": "KeyValue"
    },
    "location": "eastUs",
    "id": "/subscriptions/xxxxxx/resourceGroups/resourcegroupname/providers/Microsoft.ManagedNetworkFabric/accessControlLists/acl",
    "name": "example-Ipv4egressACL",
    "type": "microsoft.managednetworkfabric/accessControlLists",
    "systemData": {
        "createdBy": "email@address.com",
        "createdByType": "User",
        "createdAt": "2023-06-09T04:51:41.251Z",
        "lastModifiedBy": "UserId",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2023-06-09T04:51:41.251Z"
    }
}

更新 Resource Manager 參考

此步驟可讓您在建立 NNI 資源期間建立 ACL(如果提供參考則為輸入和輸出)。 建立 NNI 之後,以及在布建網路網狀架構之前,您可以對 NNI 執行重新放置。

  • ingressAclId:輸入 ACL 的參考識別碼。
  • egressAclId:輸出 ACL 的參考識別碼。

若要取得 Resource Manager 資源識別碼,請移至您所使用的訂用帳戶資源群組。

下列命令會將 NNI 資源的 Resource Manager 參考與提供的輸入和輸出 ACL 建立關聯,以更新 NNI 資源的參考。 視您的使用案例需要調整參數。

az networkfabric nni create
--resource-group "example-rg"
--fabric "example-fabric"
--resource-name "example-nniwithACL"
--nni-type "CE"
--is-management-type "True"
--use-option-b "True"
--layer2-configuration "{interfaces:['/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkDevices/example-networkDevice/networkInterfaces/example-interface'],mtu:1500}"
--option-b-layer3-configuration "{peerASN:28,vlanId:501,primaryIpv4Prefix:'10.18.0.124/30',secondaryIpv4Prefix:'10.18.0.128/30',primaryIpv6Prefix:'10:2:0:124::400/127',secondaryIpv6Prefix:'10:2:0:124::402/127'}"
--ingress-acl-id "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accesscontrollists/example-Ipv4ingressACL"
--egress-acl-id "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accesscontrollists/example-Ipv4egressACL"

顯示 ACL 詳細數據

若要顯示指定 ACL 的詳細資料,請使用下列命令:

az networkfabric acl show --resource-group "example-rg" --resource-name "example-acl"

列出 ACL

若要列出指定資源群組內的所有 ACL,請使用下列命令:

az networkfabric acl list --resource-group "ResourceGroupName"

在ISD外部網路上建立 ACL

使用下列資訊來建立隔離網域 (ISD) 外部網路的輸入和輸出 ACL。 然後,更新外部網路的 Resource Manager 資源參考。

建立ISD外部網路輸出 ACL

若要使用提供的組態,為指定的ISD外部網路建立輸出 ACL,請使用下列命令。 視您的使用案例需要調整參數。

az networkfabric acl create
--resource-group "example-rg"
--location "eastus2euap"
--resource-name "example-Ipv4egressACL"
--annotation "annotation"
--configuration-type "Inline"
--default-action "Deny"
--match-configurations "[{matchConfigurationName:'L3ISD_EXT_OPTA_EGRESS_ACL_IPV4_CE_PE',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}]}]"

預期的輸出

成功執行時,命令會以下列格式傳回所建立 ACL 的相關信息。 此輸出包含設定和狀態的詳細數據。

{
    "administrativeState": "Disabled",
    "annotation": "annotation",
    "configurationState": "Succeeded",
    "configurationType": "Inline",
    "defaultAction": "Deny",
    "id": "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accessControlLists/example-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": "L3ISD_EXT_OPTA_EGRESS_ACL_IPV4_CE_PE",
            "sequenceNumber": 1110
        }
    ],
    "name": "example-Ipv4egressACL",
    "provisioningState": "Succeeded",
    "resourceGroup": "example-rg",
    "systemData": {
        "createdAt": "2023-09-11T10:20:20.2617941Z",
        "createdBy": "email@address.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-09-11T10:20:20.2617941Z",
        "lastModifiedBy": "email@address.com",
        "lastModifiedByType": "User"
    },
    "type": "microsoft.managednetworkfabric/accesscontrollists"
}

建立ISD外部網路的輸入 ACL

若要使用提供的組態,為指定的ISD外部網路建立輸入 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:'L3ISD_EXT_OPTA_INGRESS_ACL_IPV4_CE_PE',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}]}]"

預期的輸出

成功執行時,命令會以下列格式傳回所建立 ACL 的相關信息。 此輸出包含設定和狀態的詳細數據。

{
    "administrativeState": "Disabled",
    "annotation": "annotation",
    "configurationState": "Succeeded",
    "configurationType": "Inline",
    "defaultAction": "Deny",
    "id": "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accessControlLists/example-Ipv4ingressACL",
    "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": "L3ISD_EXT_OPTA_INGRESS_ACL_IPV4_CE_PE",
            "sequenceNumber": 1110
        }
    ],
    "name": "example-Ipv4ingressACL",
    "provisioningState": "Succeeded",
    "resourceGroup": "example-rg",
    "systemData": {
        "createdAt": "2023-09-11T10:20:20.2617941Z",
        "createdBy": "email@address.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-09-11T10:27:27.2317467Z",
        "lastModifiedBy": "email@address.com",
        "lastModifiedByType": "User"
    },
    "type": "microsoft.managednetworkfabric/accesscontrollists"
}