NATインスタンスを使用して推移的なピアリング構成での通信を試してみる

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

こんにちは、マネージドサービス部テクニカルサポート課の坂口です。

先日、お客様からのお問い合わせ対応のため、NAT インスタンスを使用して推移的なピアリング構成で通信が可能か検証しました。

はじめに

推移的なピアリング構成とは

上記図の様な構成(VPC A --- VPC B --- VPC C)を指します。
VPC B を経由して VPC A から VPC C へのルーティングが出来そうではありますが、VPC ピアリングの制限事項によりサポート外となっております。
今回は、VPC B に NAT インスタンスを配置し、NAT インスタンスを経由してクライアントからサーバへ HTTP 通信可能か検証します。

docs.aws.amazon.com

VPC ピアリングでは、推移的なピアリング関係がサポートされません。例えば、VPC A と VPC B の間、および VPC A と VPC C との間に VPC ピアリング接続がある場合、VPC A 経由で VPC B から VPC C へトラフィックをルーティングすることはできません。VPC B と VPC C との間でトラフィックをルーティングするには、その VPC B と VPC C との間で VPC ピアリング接続を作成する必要があります。詳細については、「3 つの VPC が相互にピアリング接続」を参照してください。

構成

上記構成の CloudFormation テンプレートを用意していますので、参考にしてください。

CloudFormation テンプレート

AWSTemplateFormatVersion: "2010-09-09"

Mappings:
  SubnetConfig:
    VPCA:
      CIDR: '10.1.0.0/16'
    VPCB:
      CIDR: '10.2.0.0/16'
    VPCC:
      CIDR: '10.3.0.0/16'
    SubnetA:
      CIDR: '10.1.0.0/24'
    SubnetB:
      CIDR: '10.2.0.0/24'
    SubnetC:
      CIDR: '10.3.0.0/24'
  EC2Config:
    ImageId:
      ID: 'ami-079cd5448deeace01'
    InstanceType:
      Type: 't3.nano'
    PrivateIPClient:
      IP: '10.1.0.100'
    PrivateIPNAT:
      IP: '10.2.0.100'
    PrivateIPServer:
      IP: '10.3.0.100'
      
Resources:
    VPCA:
        Type: "AWS::EC2::VPC"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, VPCA, CIDR]
    VPCB:
        Type: "AWS::EC2::VPC"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, VPCB, CIDR]
    VPCC:
        Type: "AWS::EC2::VPC"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, VPCC, CIDR]

    SubnetA:
        Type: "AWS::EC2::Subnet"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, SubnetA, CIDR]
            VpcId: !Ref VPCA
    SubnetB:
        Type: "AWS::EC2::Subnet"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, SubnetB, CIDR]
            VpcId: !Ref VPCB
    SubnetC:
        Type: "AWS::EC2::Subnet"
        Properties:
            CidrBlock: !FindInMap [SubnetConfig, SubnetC, CIDR]
            VpcId: !Ref VPCC

    VPCPeeringConnectionAB:
        Type: "AWS::EC2::VPCPeeringConnection"
        Properties:
            PeerVpcId: !Ref VPCA
            VpcId: !Ref VPCB
    VPCPeeringConnectionBC:
        Type: "AWS::EC2::VPCPeeringConnection"
        Properties:
            PeerVpcId: !Ref VPCC
            VpcId: !Ref VPCB

    InternetGatewayA: 
      Type: "AWS::EC2::InternetGateway"
    InternetGatewayAttachment1: 
      Type: "AWS::EC2::VPCGatewayAttachment"
      Properties: 
        InternetGatewayId: !Ref InternetGatewayA
        VpcId: !Ref VPCA
    InternetGatewayB: 
      Type: "AWS::EC2::InternetGateway"
    InternetGatewayAttachment2: 
      Type: "AWS::EC2::VPCGatewayAttachment"
      Properties: 
        InternetGatewayId: !Ref InternetGatewayB
        VpcId: !Ref VPCB
    InternetGatewayC: 
      Type: "AWS::EC2::InternetGateway"
    InternetGatewayAttachment3: 
      Type: "AWS::EC2::VPCGatewayAttachment"
      Properties: 
        InternetGatewayId: !Ref InternetGatewayC
        VpcId: !Ref VPCC

    RouteTableA:
        Type: "AWS::EC2::RouteTable"
        Properties:
            VpcId: !Ref VPCA
    RouteTableB:
        Type: "AWS::EC2::RouteTable"
        Properties:
            VpcId: !Ref VPCB
    RouteTableC:
        Type: "AWS::EC2::RouteTable"
        Properties:
            VpcId: !Ref VPCC
    VPCARoute1:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: !FindInMap [SubnetConfig, VPCB, CIDR]
            VpcPeeringConnectionId: !Ref VPCPeeringConnectionAB
            RouteTableId: !Ref RouteTableA
    VPCARoute2:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: "0.0.0.0/0"
            GatewayId: !Ref InternetGatewayA
            RouteTableId: !Ref RouteTableA
    VPCBRoute1:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: !FindInMap [SubnetConfig, VPCA, CIDR]
            VpcPeeringConnectionId: !Ref VPCPeeringConnectionAB
            RouteTableId: !Ref RouteTableB
    VPCBRoute2:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: !FindInMap [SubnetConfig, VPCC, CIDR]
            VpcPeeringConnectionId: !Ref VPCPeeringConnectionBC
            RouteTableId: !Ref RouteTableB
    VPCBRoute3:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: "0.0.0.0/0"
            GatewayId: !Ref InternetGatewayB
            RouteTableId: !Ref RouteTableB
    VPCCRoute1:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: !FindInMap [SubnetConfig, VPCB, CIDR]
            VpcPeeringConnectionId: !Ref VPCPeeringConnectionBC
            RouteTableId: !Ref RouteTableC
    VPCCRoute2:
        Type: "AWS::EC2::Route"
        Properties:
            DestinationCidrBlock: "0.0.0.0/0"
            GatewayId: !Ref InternetGatewayC
            RouteTableId: !Ref RouteTableC
    RouteTableAssociationA:
        Type: "AWS::EC2::SubnetRouteTableAssociation"
        Properties:
          SubnetId: !Ref SubnetA
          RouteTableId: !Ref RouteTableA
    RouteTableAssociationB:
        Type: "AWS::EC2::SubnetRouteTableAssociation"
        Properties:
          SubnetId: !Ref SubnetB
          RouteTableId: !Ref RouteTableB
    RouteTableAssociationC:
        Type: "AWS::EC2::SubnetRouteTableAssociation"
        Properties:
          SubnetId: !Ref SubnetC
          RouteTableId: !Ref RouteTableC

    SecurityGroupClient:
        Type: "AWS::EC2::SecurityGroup"
        Properties:
            GroupDescription: "EC2Client"
            VpcId: !Ref VPCA
            SecurityGroupEgress: 
              - 
                CidrIp: "0.0.0.0/0"
                IpProtocol: "-1"
    SecurityGroupNAT:
        Type: "AWS::EC2::SecurityGroup"
        Properties:
            GroupDescription: "EC2NAT"
            VpcId: !Ref VPCB
            SecurityGroupIngress: 
              - 
                CidrIp: !FindInMap [SubnetConfig, VPCA, CIDR] 
                FromPort: 80
                IpProtocol: "tcp"
                ToPort: 80
            SecurityGroupEgress: 
              - 
                CidrIp: "0.0.0.0/0"
                IpProtocol: "-1"
    SecurityGroupServer:
        Type: "AWS::EC2::SecurityGroup"
        Properties:
            GroupDescription: "EC2Server"
            VpcId: !Ref VPCC
            SecurityGroupIngress: 
              - 
                CidrIp: !FindInMap [SubnetConfig, VPCB, CIDR] 
                FromPort: 80
                IpProtocol: "tcp"
                ToPort: 80
            SecurityGroupEgress: 
              - 
                CidrIp: "0.0.0.0/0"
                IpProtocol: "-1"

    InstanceProfileRole:
      Type: AWS::IAM::Role
      Properties:
        AssumeRolePolicyDocument:
          Version: "2012-10-17"
          Statement:
            - Effect: Allow
              Principal:
                Service: ec2.amazonaws.com
              Action: sts:AssumeRole
        Description: IAM Role for EC2 instances with Session Manager access
        ManagedPolicyArns:
          - "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
    InstanceProfile:
      Type: AWS::IAM::InstanceProfile
      Properties:
        Roles:
          - !Ref InstanceProfileRole

    EC2Client:
        Type: "AWS::EC2::Instance"
        Properties:
            ImageId: !FindInMap [EC2Config, ImageId, ID]
            InstanceType: !FindInMap [EC2Config, InstanceType, Type]
            IamInstanceProfile: !Ref InstanceProfile
            NetworkInterfaces:
              - AssociatePublicIpAddress: true
                DeviceIndex: 0
                GroupSet: 
                  - !Ref SecurityGroupClient
                SubnetId: !Ref SubnetA
                PrivateIpAddress: !FindInMap [EC2Config, PrivateIPClient, IP]
    EC2NAT:
        Type: "AWS::EC2::Instance"
        Properties:
            ImageId: !FindInMap [EC2Config, ImageId, ID]
            InstanceType: !FindInMap [EC2Config, InstanceType, Type]
            IamInstanceProfile: !Ref InstanceProfile
            NetworkInterfaces:
              - AssociatePublicIpAddress: true
                DeviceIndex: 0
                GroupSet: 
                  - !Ref SecurityGroupNAT
                SubnetId: !Ref SubnetB
                PrivateIpAddress: !FindInMap [EC2Config, PrivateIPNAT, IP]
            SourceDestCheck: false
            UserData:
              Fn::Base64: !Sub
                - |
                  #!/bin/bash
                  sudo dnf install -y nftables
                  sudo nft add table nat-table
                  sudo nft -- add chain nat-table prerouting { type nat hook prerouting priority -100 \; }
                  sudo nft add chain nat-table postrouting { type nat hook postrouting priority 100 \; }
                  sudo nft add rule nat-table prerouting ip saddr ${ClientIP} ip daddr ${NATIP} tcp dport 80 log dnat to ${ServerIP}
                  sudo nft add rule nat-table postrouting ip saddr ${ClientIP} oifname "$(ip -o link show device-number-0 | awk -F': ' '{print $2}')" tcp dport 80 log snat to ${NATIP}
                  sudo nft list table nat | sudo tee /etc/nftables/nat.nft
                  echo 'include "/etc/nftables/nat.nft"' | sudo tee -a /etc/sysconfig/nftables.conf
                  sudo systemctl enable nftables
                  sudo systemctl start nftables
                  echo net.ipv4.ip_forward=1 | sudo tee /etc/sysctl.d/99-ip_forward.conf
                  sudo sysctl --system
                - {
                    ClientIP: !FindInMap [EC2Config, PrivateIPClient, IP],
                    NATIP: !FindInMap [EC2Config, PrivateIPNAT, IP],
                    ServerIP: !FindInMap [EC2Config, PrivateIPServer, IP]
                  }
    EC2Server:
        Type: "AWS::EC2::Instance"
        Properties:
            ImageId: !FindInMap [EC2Config, ImageId, ID]
            InstanceType: !FindInMap [EC2Config, InstanceType, Type]
            IamInstanceProfile: !Ref InstanceProfile
            NetworkInterfaces:
              - AssociatePublicIpAddress: true
                DeviceIndex: 0
                GroupSet: 
                  - !Ref SecurityGroupServer
                SubnetId: !Ref SubnetC
                PrivateIpAddress: !FindInMap [EC2Config, PrivateIPServer, IP]
            UserData:
              Fn::Base64: |
                #!/bin/bash
                sudo dnf install -y nginx
                sudo systemctl enable nginx
                sudo systemctl start nginx

NATインスタンスの設定

今回、NAT インスタンスは Amazon Linux 2023 AMI を使用します。
NAT インスタンス用の AMI が AWS 公式から用意されていますが、Amazon Linux ベースとなっており、2023年12月31日にサポートが切れるため自前で構築します。

docs.aws.amazon.com

NAT に関する設定は、EC2のユーザーデータにて各種設定を実施していますので、順番に解説します。

nftables インストール

sudo dnf install -y nftables

nftables テーブルの作成

nat-table というテーブルを作成します。

sudo nft add table nat-table

nftables チェーンの作成

作成したテーブルに、nat タイプのチェーンを作成します。

DNAT 用のチェーン
sudo nft -- add chain nat-table prerouting { type nat hook prerouting priority -100 \; }

※ add 前に「--」を記載しているのは、負の priority 値を nft コマンドのオプションとして解釈しないようにするためです。

SNAT 用のチェーン
sudo nft add chain nat-table postrouting { type nat hook postrouting priority 100 \; }

nftables ルールの作成

作成したチェーンにルールを追加します。

DNAT ルールの追加
sudo nft add rule nat-table prerouting ip saddr 10.1.0.100 ip daddr 10.2.0.100 tcp dport 80 log dnat to 10.3.0.100

このルールは、送信元 IP アドレスが 10.1.0.100(クライアント)、宛先 IP アドレスが 10.2.0.100(NAT インスタンス)、宛先ポートが TCP 80 のパケットにマッチした場合に宛先 IP アドレスを 10.3.0.100(サーバ)に変更するルールとなります。

SNAT ルールの追加
sudo nft add rule nat-table postrouting ip saddr 10.1.0.100 oifname "$(ip -o link show device-number-0 | awk -F': ' '{print $2}')" tcp dport 80 log snat to 10.2.0.100

このルールは、送信元 IP アドレスが 10.1.0.100(クライアント)、出力インターフェースが ens5、宛先ポートが TCP 80 のパケットにマッチした場合に送信元 IP アドレスを 10.2.0.100(NATインスタンス)に変更するルールとなります。
※ oifname では、出力インターフェースを指定する必要がありますが、OS 等により可変値のため、ip コマンドを実行し取得しております。

NAT 処理のイメージ図は以下のとおりです。

nftables 設定の保存

現在の設定をコンフィグファイルへ保存し、起動時に読み込まれるようにします。

sudo nft list table nat | sudo tee /etc/nftables/nat.nft
echo 'include "/etc/nftables/nat.nft"' | sudo tee -a /etc/sysconfig/nftables.conf

nftables サービス起動

nftables の自動起動設定およびサービスを開始します。

sudo systemctl enable nftables
sudo systemctl start nftables

IPフォワードの有効化

IPフォワードの有効化および永続化を行います。

echo net.ipv4.ip_forward=1 | sudo tee /etc/sysctl.d/99-ip_forward.conf
sudo sysctl --system

検証

curl を用いた通信

クライアント(10.1.0.100)から NAT インスタンス(10.2.0.100)へ curl で HTTP 通信を行うと nginx のデフォルトページが表示されます。

sh-5.2$ curl http://10.2.0.100
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
sh-5.2$

次にサーバ側のアクセスログを確認すると、送信元が NAT インスタンス(10.2.0.100)となっている事がわかります。

sh-5.2$ sudo tail -f /var/log/nginx/access.log
10.2.0.100 - - [21/Sep/2023:07:10:06 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/8.2.1" "-"

各インスタンスのパケットキャプチャ

各インスタンスのパケットキャプチャを確認すると、 NAT 変換され通信出来ている事がわかります。

クライアント
sh-5.2$ sudo tcpdump port 80 -nn
dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens5, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:49:10.949419 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [S], seq 3547929033, win 62727, options [mss 8961,sackOK,TS val 3005085968 ecr 0,nop,wscale 6], length 0
07:49:10.955992 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [S.], seq 2240673688, ack 3547929034, win 62643, options [mss 8961,sackOK,TS val 2456879145 ecr 3005085968,nop,wscale 6], length 0
07:49:10.956779 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 0
07:49:10.956864 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [P.], seq 1:74, ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 73: HTTP: GET / HTTP/1.1
07:49:10.957613 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [.], ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 0
07:49:10.957806 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [P.], seq 1:854, ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 853: HTTP: HTTP/1.1 200 OK
07:49:10.957814 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958055 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [F.], seq 74, ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.959059 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [F.], seq 854, ack 75, win 978, options [nop,nop,TS val 2456879149 ecr 3005085976], length 0
07:49:10.959075 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 855, win 968, options [nop,nop,TS val 3005085977 ecr 2456879149], length 0
NAT インスタンス
sh-5.2$ sudo tcpdump port 80 -nn
dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens5, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:49:10.949718 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [S], seq 3547929033, win 62727, options [mss 8961,sackOK,TS val 3005085968 ecr 0,nop,wscale 6], length 0
07:49:10.954430 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [S], seq 3547929033, win 62727, options [mss 8961,sackOK,TS val 3005085968 ecr 0,nop,wscale 6], length 0
07:49:10.954716 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [S.], seq 2240673688, ack 3547929034, win 62643, options [mss 8961,sackOK,TS val 2456879145 ecr 3005085968,nop,wscale 6], length 0
07:49:10.954731 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [S.], seq 2240673688, ack 3547929034, win 62643, options [mss 8961,sackOK,TS val 2456879145 ecr 3005085968,nop,wscale 6], length 0
07:49:10.957066 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 0
07:49:10.957084 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 0
07:49:10.957121 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [P.], seq 1:74, ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 73: HTTP: GET / HTTP/1.1
07:49:10.957125 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [P.], seq 1:74, ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 73: HTTP: GET / HTTP/1.1
07:49:10.957368 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [.], ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 0
07:49:10.957378 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [.], ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 0
07:49:10.957575 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [P.], seq 1:854, ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 853: HTTP: HTTP/1.1 200 OK
07:49:10.957578 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [P.], seq 1:854, ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 853: HTTP: HTTP/1.1 200 OK
07:49:10.958079 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958088 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958390 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [F.], seq 74, ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958395 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [F.], seq 74, ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958637 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [F.], seq 854, ack 75, win 978, options [nop,nop,TS val 2456879149 ecr 3005085976], length 0
07:49:10.958641 IP 10.2.0.100.80 > 10.1.0.100.54012: Flags [F.], seq 854, ack 75, win 978, options [nop,nop,TS val 2456879149 ecr 3005085976], length 0
07:49:10.959341 IP 10.1.0.100.54012 > 10.2.0.100.80: Flags [.], ack 855, win 968, options [nop,nop,TS val 3005085977 ecr 2456879149], length 0
07:49:10.959349 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 855, win 968, options [nop,nop,TS val 3005085977 ecr 2456879149], length 0
サーバ
sh-5.2$ sudo tcpdump port 80 -nn
dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens5, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:49:10.954564 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [S], seq 3547929033, win 62727, options [mss 8961,sackOK,TS val 3005085968 ecr 0,nop,wscale 6], length 0
07:49:10.954596 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [S.], seq 2240673688, ack 3547929034, win 62643, options [mss 8961,sackOK,TS val 2456879145 ecr 3005085968,nop,wscale 6], length 0
07:49:10.957198 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 0
07:49:10.957253 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [P.], seq 1:74, ack 1, win 981, options [nop,nop,TS val 3005085975 ecr 2456879145], length 73: HTTP: GET / HTTP/1.1
07:49:10.957264 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [.], ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 0
07:49:10.957473 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [P.], seq 1:854, ack 74, win 978, options [nop,nop,TS val 2456879148 ecr 3005085975], length 853: HTTP: HTTP/1.1 200 OK
07:49:10.958192 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958487 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [F.], seq 74, ack 854, win 968, options [nop,nop,TS val 3005085976 ecr 2456879148], length 0
07:49:10.958538 IP 10.3.0.100.80 > 10.2.0.100.54012: Flags [F.], seq 854, ack 75, win 978, options [nop,nop,TS val 2456879149 ecr 3005085976], length 0
07:49:10.959451 IP 10.2.0.100.54012 > 10.3.0.100.80: Flags [.], ack 855, win 968, options [nop,nop,TS val 3005085977 ecr 2456879149], length 0

まとめ

本来 VPC A から VPC C への通信ですが、NAT にて、VPC B から VPC C への通信に変換することで推移的なピアリング構成でも通信が可能となります。
ご参考いただけますと幸いです。

坂口 大樹 (記事一覧)

マネージドサービス部テクニカルサポート課

2023年3月にサーバーワークス入社。

スパイスカレーが好きです。