在 Azure Operator Nexus 中,網路對網路互連(NNI)層級的存取控制清單(ACL)用於Permit和Deny動作,有助於保護管理虛擬私人網路(VPN)上的安全殼層(SSH)存取。 在建立 NNI 資源之前,您可以建立輸入和輸出 ACL,然後在 NNI 承載中參考這些 ACL。 您必須先建立參考的輸入和輸出 ACL,才能佈建網路網狀架構。
以下是在 NNI 上建立 ACL 的高階步驟:
- 建立 NNI 輸入和輸出 ACL。
- 更新管理 NNI 中的 Azure Resource Manager 資源參考。
- 建立 NNI 並佈建網路網狀架構。
參數使用指引
| 參數 | Description | 範例或範圍 |
|---|---|---|
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. 允許的值: DestinationPort、 SourcePort。 |
protocolTypes |
需要匹配的協議。 |
[tcp, udp, range[1-2, 1, 2]]。 如果是協定號,則應在 的 1-255範圍內。 |
vlanMatchCondition |
需要匹配的VLAN匹配條件。 | |
layer4Protocol |
第 4 層協定。 | 應該是TCP或UDP。 |
ipCondition |
需要比對的IP條件。 | |
actions |
根據比對條件要採取的動作。 | 範例: permit. |
configuration-type |
設定類型,可以是內嵌或檔案。 目前,Azure Operator Nexus 僅支援內嵌。 | 範例: inline. |
您還應該注意以下限制:
- 內嵌埠和內嵌 VLAN 是使用
azcli來定義埠或 VLAN 的靜態方式。 -
portGroupNames及vlanGroupNames是定義埠及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的參考ID。 -
egressAclId:輸出ACL的參考ID。
若要取得 Resource Manager 資源識別碼,請移至您所使用的訂用帳戶的資源群組。
下列命令透過將 NNI 資源與提供的入口和出口 ACL 產生關聯來更新資源管理參考。 根據您的使用案例視需要調整參數。
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"
}