presents by IT Consulting 109

AWS – ネットワークACL情報の取得

概要

ネットワークACLの情報を取得する方法について記載しています。

ネットワークACL
ネットワークアクセスコントロールリスト (ACL) は、1 つ以上のサブネットのインバウンドトラフィックとアウトバウンドトラフィックを制御するファイアウォールとして動作する、VPC 用のセキュリティのオプションレイヤーです。セキュリティの追加レイヤーを VPC に追加するには、セキュリティグループと同様のルールを指定したネットワーク ACL をセットアップできます。

 

手順

ネットワークACLの情報を取得するには次のコマンドを実行します。

aws ec2 describe-network-acls

TEXT

NETWORKACLS     True    acl-8dfbb3e*    vpc-8db025e*
ASSOCIATIONS    aclassoc-33811b4*       acl-8dfbb3e*    subnet-da2db88*
ASSOCIATIONS    aclassoc-fdcaf68*       acl-8dfbb3e*    subnet-04c4084*
ASSOCIATIONS    aclassoc-4f801a3*       acl-8dfbb3e*    subnet-0fa5fd4*
ASSOCIATIONS    aclassoc-77841e0*       acl-8dfbb3e*    subnet-112cb94*
ENTRIES 0.0.0.0/0       True    -1      allow   100
ENTRIES 0.0.0.0/0       True    -1      deny    32767
ENTRIES 0.0.0.0/0       False   -1      allow   100
ENTRIES 0.0.0.0/0       False   -1      deny    32767
NETWORKACLS     True    acl-ec54f28*    vpc-9e7f74fa
ASSOCIATIONS    aclassoc-d85793a*       acl-ec54f28*    subnet-f714f1a*
ASSOCIATIONS    aclassoc-9746bfe*       acl-ec54f28*    subnet-d2c798f*
ASSOCIATIONS    aclassoc-d95793a*       acl-ec54f28*    subnet-5733911*
ENTRIES 0.0.0.0/0       True    -1      allow   100
ENTRIES 0.0.0.0/0       True    -1      deny    32767
ENTRIES 0.0.0.0/0       False   -1      allow   100
ENTRIES 0.0.0.0/0       False   -1      deny    32767

TABLE

+-------------------------------------------------------------------+
|                        DescribeNetworkAcls                        |
+-------------------------------------------------------------------+
||                           NetworkAcls                           ||
|+-----------------+-----------------------+-----------------------+|
||    IsDefault    |     NetworkAclId      |         VpcId         ||
|+-----------------+-----------------------+-----------------------+|
||  True           |  acl-8dfbb3e*         |  vpc-8db025e*         ||
|+-----------------+-----------------------+-----------------------+|
|||                         Associations                          |||
||+--------------------------+----------------+-------------------+||
|||  NetworkAclAssociationId | NetworkAclId   |     SubnetId      |||
||+--------------------------+----------------+-------------------+||
|||  aclassoc-33811b4*       |  acl-8dfbb3e*  |  subnet-da2db88*  |||
|||  aclassoc-fdcaf68*       |  acl-8dfbb3e*  |  subnet-04c4084*  |||
|||  aclassoc-4f801a3*       |  acl-8dfbb3e*  |  subnet-0fa5fd4*  |||
|||  aclassoc-77841e0*       |  acl-8dfbb3e*  |  subnet-112cb94*  |||
||+--------------------------+----------------+-------------------+||
|||                            Entries                            |||
||+-----------+---------+-----------+--------------+--------------+||
||| CidrBlock | Egress  | Protocol  | RuleAction   | RuleNumber   |||
||+-----------+---------+-----------+--------------+--------------+||
|||  0.0.0.0/0|  True   |  -1       |  allow       |  100         |||
|||  0.0.0.0/0|  True   |  -1       |  deny        |  32767       |||
|||  0.0.0.0/0|  False  |  -1       |  allow       |  100         |||
|||  0.0.0.0/0|  False  |  -1       |  deny        |  32767       |||
||+-----------+---------+-----------+--------------+--------------+||
||                           NetworkAcls                           ||
|+-----------------+-----------------------+-----------------------+|
||    IsDefault    |     NetworkAclId      |         VpcId         ||
|+-----------------+-----------------------+-----------------------+|
||  True           |  acl-ec54f28*         |  vpc-9e7f74fa         ||
|+-----------------+-----------------------+-----------------------+|
|||                         Associations                          |||
||+--------------------------+----------------+-------------------+||
|||  NetworkAclAssociationId | NetworkAclId   |     SubnetId      |||
||+--------------------------+----------------+-------------------+||
|||  aclassoc-d85793a*       |  acl-ec54f28*  |  subnet-f714f1a*  |||
|||  aclassoc-9746bfe*       |  acl-ec54f28*  |  subnet-d2c798f*  |||
|||  aclassoc-d95793a*       |  acl-ec54f28*  |  subnet-5733911*  |||
||+--------------------------+----------------+-------------------+||
|||                            Entries                            |||
||+-----------+---------+-----------+--------------+--------------+||
||| CidrBlock | Egress  | Protocol  | RuleAction   | RuleNumber   |||
||+-----------+---------+-----------+--------------+--------------+||
|||  0.0.0.0/0|  True   |  -1       |  allow       |  100         |||
|||  0.0.0.0/0|  True   |  -1       |  deny        |  32767       |||
|||  0.0.0.0/0|  False  |  -1       |  allow       |  100         |||
|||  0.0.0.0/0|  False  |  -1       |  deny        |  32767       |||
||+-----------+---------+-----------+--------------+--------------+||

JSON

{
    "NetworkAcls": [
        {
            "Associations": [
                {
                    "SubnetId": "subnet-da2db88*",
                    "NetworkAclId": "acl-8dfbb3e*",
                    "NetworkAclAssociationId": "aclassoc-33811b4*"
                },
                {
                    "SubnetId": "subnet-04c4084*",
                    "NetworkAclId": "acl-8dfbb3e*",
                    "NetworkAclAssociationId": "aclassoc-fdcaf68*"
                },
                {
                    "SubnetId": "subnet-0fa5fd4*",
                    "NetworkAclId": "acl-8dfbb3e*",
                    "NetworkAclAssociationId": "aclassoc-4f801a3*"
                },
                {
                    "SubnetId": "subnet-112cb94*",
                    "NetworkAclId": "acl-8dfbb3e*",
                    "NetworkAclAssociationId": "aclassoc-77841e0*"
                }
            ],
            "NetworkAclId": "acl-8dfbb3e*",
            "VpcId": "vpc-8db025e*",
            "Tags": [],
            "Entries": [
                {
                    "RuleNumber": 100,
                    "Protocol": "-1",
                    "Egress": true,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "allow"
                },
                {
                    "RuleNumber": 32767,
                    "Protocol": "-1",
                    "Egress": true,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "deny"
                },
                {
                    "RuleNumber": 100,
                    "Protocol": "-1",
                    "Egress": false,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "allow"
                },
                {
                    "RuleNumber": 32767,
                    "Protocol": "-1",
                    "Egress": false,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "deny"
                }
            ],
            "IsDefault": true
        },
        {
            "Associations": [
                {
                    "SubnetId": "subnet-f714f1a*",
                    "NetworkAclId": "acl-ec54f28*",
                    "NetworkAclAssociationId": "aclassoc-d85793a*"
                },
                {
                    "SubnetId": "subnet-d2c798f*",
                    "NetworkAclId": "acl-ec54f28*",
                    "NetworkAclAssociationId": "aclassoc-9746bfe*"
                },
                {
                    "SubnetId": "subnet-5733911*",
                    "NetworkAclId": "acl-ec54f28*",
                    "NetworkAclAssociationId": "aclassoc-d95793a*"
                }
            ],
            "NetworkAclId": "acl-ec54f28*",
            "VpcId": "vpc-9e7f74fa",
            "Tags": [],
            "Entries": [
                {
                    "RuleNumber": 100,
                    "Protocol": "-1",
                    "Egress": true,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "allow"
                },
                {
                    "RuleNumber": 32767,
                    "Protocol": "-1",
                    "Egress": true,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "deny"
                },
                {
                    "RuleNumber": 100,
                    "Protocol": "-1",
                    "Egress": false,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "allow"
                },
                {
                    "RuleNumber": 32767,
                    "Protocol": "-1",
                    "Egress": false,
                    "CidrBlock": "0.0.0.0/0",
                    "RuleAction": "deny"
                }
            ],
            "IsDefault": true
        }
    ]
}

 

出力結果から以下の項目が取得できます。

項目 形式 説明 対応箇所
Associations list ネットワークACLと1つまたは複数のサブネット間の関連付け。
 NetworkAclAssociationId   string ネットワークACLの協会ID。 ※不明 
 NetworkAclId string ネットワークACLのID。 概要 > ネットワーク ACL ID
 SubnetId string  サブネットのID。 サブネットの関連付け > サブネット
Entries list ネットワークACL内の1つまたは複数のエントリ(ルール)。
 CidrBlock string CIDRブロック。 サブネットの関連付け > IPv4 CIDR
 Egress string 出力。 True : インバウンドルール
False : アウトバウンドルール
 IcmpTypeCode  structure ICMPタイプコード。  ※不明
  Code integer コード。  ※不明
  Type integer タイプ。  ※不明
 Ipv6CidrBlock   IPv6 CIDRブロック。 サブネットの関連付け > IPv6 CIDR
 PortRange structure ポート範囲。 インバウンドルール > ポート範囲
アウトバウンドルール > ポート範囲
  From integer 送信元。 インバウンドルール > ポート範囲
アウトバウンドルール > ポート範囲
  To integer 送信先。 インバウンドルール > ポート範囲
アウトバウンドルール > ポート範囲
 Protocol string プロトコル。 インバウンドルール > プロトコル
アウトバウンドルール > プロトコル
 RuleAction string ルールに一致するトラフィックを許可するか拒否するかを示します。 インバウンドルール > 許可/拒否
アウトバウンドルール > 許可拒否
 RuleNumber integer エントリのルール番号。 ACLエントリは、ルール番号によって昇順に処理されます。 インバウンドルール > #ルール
アウトバウンドルール > #ルール
IsDefault boolean これがVPCのデフォルトネットワークACLかどうかを示します。 概要 > デフォルト
NetworkAclId string ネットワークACLのID。 概要 > ネットワーク ACL ID
Tags list ネットワークACLに割り当てられたタグ。 タグ
 Key string タグ。 タグ > キー
 Value string タグの値。 タグ > 値
この記事を書いた人
名前:TRUE's。 千葉県育ち、神奈川県在住のIT系フリーエンジニア。 IT系のナレッジサイトを不定期で更新中。 フォトグラファー兼エンジニアとして日々勤しんでいる。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です