Transit Gateway が VPC Flow Logs をサポートしました

記事タイトルとURLをコピーする

CI2部 技術2課の山﨑です。

7月にTransit Gateway が VPC Flow Logs をサポートしましたので簡単にご紹介したいと思います。

おさらい

VPC Flow Logs とは?

VPC のENI間で行き来する IP トラフィックに関する情報をキャプチャできるようにする簡易的なパケットキャプチャ機能です。。VPC FlowLogsはENI単位でログストリームが出力されます。そのため以下のようにENIを利用するサービスであれば送受信トラフィックを確認することが可能です。

  • Elastic Load Balancing
  • Amazon RDS
  • Amazon ElastiCache
  • Amazon Redshift
  • Amazon WorkSpaces
  • NAT Gateway
  • Transit Gateway
  • Amazon Elastic Compute Cloud

ただし、以下のフローログは記録することはできません。

  • Amazon DNS サーバーに接続したときにインスタンスによって生成されるトラフィック。独自の DNS サーバーを使用する場合は、その DNS サーバーへのすべてのトラフィックが記録されます。
  • Amazon Windows ライセンスのアクティベーション用に Windows インスタンスによって生成されたトラフィック。
  • インスタンスメタデータ用に 169.254.169.254 との間を行き来するトラフィック。
  • Amazon Time Sync Service の 169.254.169.123 との間でやり取りされるトラフィック。
  • DHCP トラフィック。
  • デフォルト VPC ルーターの予約済み IP アドレスへのトラフィック。
  • エンドポイントのネットワークインターフェイスと Network Load Balancer のネットワークインターフェイスの間のトラフィック。

docs.aws.amazon.com

ちなみにVPC Flow Logsは「VPC」と書いているのでVPCに作成するもの、と考えてしまいがちですが、以下のサービス単体でも設定が可能です

  • VPC
  • サブネット
  • ENI

その他、VPC Flow Logsについては、以下のブログも合わせてご覧ください

blog.serverworks.co.jp

blog.serverworks.co.jp

blog.serverworks.co.jp

アップデート概要

Transit Gateway が VPC Flow Logs をサポートしました

VPC/サブネット/ENIに加えて、以下のAWSリソースでもVPC Flow Logsを作成することができるようになりました。

  • Transit Gateway
  • Transit Gateway Attachment

上記2つの違いですが、Transit GatewayでVPC Flow Logsを作成した場合はTransit Gatewayを経由した通信全てをキャプチャできます。これによりVPCのENI間だけでなく、Direct Connect や Site to Site VPN上のトラフィックをキャプチャすることができるようになります。

Introducing VPC Flow Logs for AWS Transit Gateway | Networking & Content Delivery

Transit Gateway が取得可能なVPC Flow Logs のログレコードについて

以下、AWSニュースブログに掲載されている取得可能なログレコードの引用です

Introducing VPC Flow Logs for AWS Transit Gateway | Networking & Content Delivery

  • version: Indicates the version in which the field was introduced. The default format includes all version 2 fields, in the same order that they appear in this list.
  • tgw-id: The ID of the Transit Gateway for which the traffic is recorded
  • tgw-attachment-id: The ID of the Transit Gateway attachment for which the traffic is recorded.
  • srcaddr: The source IP address
  • dstaddr: The destination IP address
  • srcport: The source port of the traffic.
  • dstport: The destination port of the traffic.
  • protocol: The IANA protocol number of the traffic. For more information, see Assigned Internet Protocol Numbers.
  • packets: The number of packets transferred during the flow.
  • bytes: The number of bytes transferred during the flow.
  • start: The timestamp when the first packet of the flow was received within the aggregation interval.
  • end: The timestamp when the last packet of the flow was received within the aggregation interval.
  • packets-lost-no-route: Packets lost due to no route
  • packets-lost-blackhole: Packets lost due to black hole
  • packets-lost-mtu-exceeded: Packets lost due to size exceeded MTU
  • packets-loss-ttl: Packets lost due to time to live expiry
  • tgw-src-vpc-account-id: The AWS account ID of the VPC for source traffic
  • tgw-dst-vpc-account-id: The AWS account ID of the VPC for destination traffic
  • tgw-src-vpc-id: The ID of the source VPC
  • tgw-dst-vpc-id: The ID of the destination VPC
  • tgw-src-subnet-id: The ID of the source Transit Gateway attachment subnet for the flow.
  • tgw-dst-subnet-id: The ID of the destination Transit Gateway attachment subnet for the flow.
  • tgw-src-eni: The ID of the source Transit Gateway attachment ENI for the flow.
  • tgw-dst-eni: The ID of the destination Transit Gateway attachment ENI for the flow.
  • tcp-flags: The bitmask value for the following TCP flags: SYN, SYN-ACK, FIN, RST, ACK
  • type: The type of traffic. Possible values are IPV4 | IPv6 | EFA.
  • region: ID of the AWS Region for the Transit Gateway.
  • tgw-src-az-id: ID of the Source Availability Zone.
  • tgw-dst-az-id: ID of the Destination Availability Zone
  • flow-direction: Direction of flow with respect to the Transit Gateway attachment where traffic is captured. Possible values: ingress | egress.
  • pkt-src-aws-service: The name of the AWS Service for source IP Address if applicable
  • pkt-dst-aws-service: The name of the AWS Service for destination IP Address if applicable
  • resource-type: Type of flow log resource, Transit Gateway or Transit Gateway attachment
  • account-id: The AWS account ID of the owner of the source transit gateway.

はい、見ているだけでお腹がいっぱいですね(笑)

ということで、VPC Flow Logs作成時にログレコードの形式は「カスタム形式」を選択して必要なログレコードだけ出力するように設定するのがベターかと思います。

まとめ

以上、Transit Gateway が新たにサポートした VPC Flow Logs に関するご紹介でした

山﨑 翔平 (Shohei Yamasaki) 記事一覧はコチラ

2019/12〜2023/2までクラウドインテグレーション部でお客様のAWS導入支援を行っていました。現在はIE(インターナルエデュケーション)課にて採用周りのお手伝いや新卒/中途オンボーディングの業務をしています。2023 Japan AWS Top Engineers/2023 Japan AWS Ambassadors