DescribeNetworkAcls与 a 一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

DescribeNetworkAcls与 a 一起使用 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" } ] }

有关更多信息,请参阅《AWS VPC用户指南》ACLs中的 “网络”。

PowerShell
用于 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中的。