DescribeNetworkAcls 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeNetworkAcls 搭配 CLI 使用

下列程式碼範例示範如何使用 DescribeNetworkAcls

CLI
AWS CLI

描述您的網路 ACLs

下列describe-network-acls範例會擷取網路 ACLs 的詳細資訊。

aws ec2 describe-network-acls

輸出:

{ "NetworkAcls": [ { "Associations": [ { "NetworkAclAssociationId": "aclassoc-0c1679dc41EXAMPLE", "NetworkAclId": "acl-0ea1f54ca7EXAMPLE", "SubnetId": "subnet-0931fc2fa5EXAMPLE" } ], "Entries": [ { "CidrBlock": "0.0.0.0/0", "Egress": true, "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 100 }, { "CidrBlock": "0.0.0.0/0", "Egress": true, "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32767 }, { "CidrBlock": "0.0.0.0/0", "Egress": false, "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 100 }, { "CidrBlock": "0.0.0.0/0", "Egress": false, "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32767 } ], "IsDefault": true, "NetworkAclId": "acl-0ea1f54ca7EXAMPLE", "Tags": [], "VpcId": "vpc-06e4ab6c6cEXAMPLE", "OwnerId": "111122223333" }, { "Associations": [], "Entries": [ { "CidrBlock": "0.0.0.0/0", "Egress": true, "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 100 }, { "Egress": true, "Ipv6CidrBlock": "::/0", "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 101 }, { "CidrBlock": "0.0.0.0/0", "Egress": true, "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32767 }, { "Egress": true, "Ipv6CidrBlock": "::/0", "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32768 }, { "CidrBlock": "0.0.0.0/0", "Egress": false, "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 100 }, { "Egress": false, "Ipv6CidrBlock": "::/0", "Protocol": "-1", "RuleAction": "allow", "RuleNumber": 101 }, { "CidrBlock": "0.0.0.0/0", "Egress": false, "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32767 }, { "Egress": false, "Ipv6CidrBlock": "::/0", "Protocol": "-1", "RuleAction": "deny", "RuleNumber": 32768 } ], "IsDefault": true, "NetworkAclId": "acl-0e2a78e4e2EXAMPLE", "Tags": [], "VpcId": "vpc-03914afb3eEXAMPLE", "OwnerId": "111122223333" } ] }

如需詳細資訊,請參閱 ACLs 使用者指南中的 Network AWS VPC

PowerShell
for PowerShell 工具

範例 1:此範例說明指定的網路 ACL。

Get-EC2NetworkAcl -NetworkAclId acl-12345678

輸出:

Associations : {aclassoc-1a2b3c4d} Entries : {Amazon.EC2.Model.NetworkAclEntry, Amazon.EC2.Model.NetworkAclEntry} IsDefault : False NetworkAclId : acl-12345678 Tags : {Name} VpcId : vpc-12345678

範例 2:此範例說明指定網路 ACL 的規則。

(Get-EC2NetworkAcl -NetworkAclId acl-12345678).Entries

輸出:

CidrBlock : 0.0.0.0/0 Egress : True IcmpTypeCode : PortRange : Protocol : -1 RuleAction : deny RuleNumber : 32767 CidrBlock : 0.0.0.0/0 Egress : False IcmpTypeCode : PortRange : Protocol : -1 RuleAction : deny RuleNumber : 32767

範例 3:此範例說明您的所有網路 ACLs。

Get-EC2NetworkAcl
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 DescribeNetworkAcls