ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [AWS] AWS to GCP Site-to-Site VPN 연결하기
    Public Cloud/AWS 2024. 5. 31. 17:37

    안녕하세요

    남영재입니다.

     

    오늘은 AWS 와 GCP 간 VPN 연결을 해보겠습니다.

     

    퍼블릭 클라우드 간 연결이다보니 양쪽 다 HA구성이 기본적으로 제공됩니다.

     
    목표 구성도
     
    [GCP]

     

    1. VPC 만들기

    gcloud compute networks create gc-vpc --subnet-mode custom --bgp-routing-mode global

     

    2. VPN Gateway 만들기

    gcloud compute vpn-gateways create gcloud-vpn-gw --network gc-vpc --region asia-northeast3

    3. 라우터 만들기

    gcloud compute routers create gc-router --region asia-northeast3 \
    --network gc-vpc \
    --asn 65002 \
    --advertisement-mode custom \
    --set-advertisement-groups all_subnets

     

    4. 고가용성 VPN 터널 만들기

     

    Google Cloud HA VPN 만들기

     

    Google Cloud VPN Gateway를 생성합니다. 테스트 환경은 모두 서울 리전에서 수행하겠습니다.

     

     

    VPN Gateway를 생성하면 터널추가 메뉴가 이어집니다. 아래 화면이 보이신다면 지금까지는 문제없이 수행하고 있는겁니다.

     

    위 과정까지 진행했다면 잠시 AWS Console 로 돌아가서 Google Cloud의 Peer VPN Gateway주소가 될 AWS VPN IP를 획득해야 합니다.

     

    AWS 화면으로 전환하기 전에 Google 에서 제공한 인터페이스의 Public IP 2개를 복사합니다.

    • 0: 34.64.64.122 , 1: 34.64.128.171
    위 아이피는 AWS 의 CGW(Customer Gateway)로 등록될 예정입니다.
     
    [AWS]로 돌아가서

     

    1. CGW 만들기

    CLI
    aws ec2 create-customer-gateway --type ipsec.1 --public-ip INTERFACE_0_IP_ADDRESS --bgp-asn GOOGLE_ASN
     
    aws ec2 create-customer-gateway --type ipsec.1 --public-ip INTERFACE_1_IP_ADDRESS --bgp-asn GOOGLE_ASN

     

    ex)
    aws ec2 create-customer-gateway --type ipsec.1 --public-ip 34.64.64.122 --bgp-asn 65002
    aws ec2 create-customer-gateway --type ipsec.1 --public-ip 34.64.128.171 --bgp-asn 65002

     

     

     

    WEB Console

     

    2. AWS Virtual Private Gateway 만들기

     

    aws ec2 create-vpn-gateway --type ipsec.1 --amazon-side-asn AWS_SIDE_ASN
     
    AWS_SIDE_ASN을 AWS 측의 ASN으로 바꿉니다.

     

    이 명령어는 다음 예시와 비슷하게 표시됩니다.

    aws ec2 create-vpn-gateway --type ipsec.1 --amazon-side-asn 65001

     

     

     

    3. Virtual Private Gateway VPC 에 연결

    aws ec2 attach-vpn-gateway --vpn-gateway-id VPN_GATEWAY_ID --vpc-id VPC_ID
     

    4. Site-to-Site VPN Connection 생성

     

     

     

    AWS 측에서 생성한 VPN 연결에서 Configuration을 다운로드하여

    1. IKE Version

    2. Pre-Shared Key 

    3. Outside Address 와 Inside Address

    를 복사해 둡니다.

     

    각 AWS VPN Connection은 2개의 터널을 가지고 있습니다.

    따라서 총 4개의 Outside Public IP를 제공합니다. 이 4개의 IP는 Google Cloud의 Peer Gateway Interface로 등록할 예정입니다.

     

    아래 그림 참고. 총 2개의 Configuration 다운로드 필요.

     

     

     

     

     

    여기까지 진행하고 다시 Google Cloud Console로 돌아갑니다.

     
    [GCP]

    1. GCP peer Gateway 만들기

    CLI
     
    gcloud compute external-vpn-gateways create peer-gateway-name --interfaces 0=13.124.63.56,1=43.203.37.194,2=13.124.205.111,3=13.209.243.165

     

    WEB Console

    AWS VPN 외부용 아이피 넣어서 생성.
    피어 VPN 게이트웨이와 Cloud Router를 선택하고 터널 4개 만들기를 고릅니다.
     

    AWS VPN 연결 생성시 지정한 IKE 버전을 고르고(우리는 v2를 선택했습니다)
    사전 공유키를 복사하여 붙여 넣습니다.
     
    총 4개의 터널을 각 인터페이스에 맞게 생성합니다.
    [1]Cloud VPN Gateway Interface 0 : Peer VPN Gateway Interface 0
    [2]Cloud VPN Gateway Interface 0 : Peer VPN Gateway Interface 1

     

    [3]Cloud VPN Gateway Interface 1 : Peer VPN Gateway Interface 2
    [4]Cloud VPN Gateway Interface 1 : Peer VPN Gateway Interface 3

     

    터널을 모두 만들었다면 BGP 세션을 구성해야 합니다.

     

        AWS VPN Connection 에서 내려받은 Configuration 파일 활용

    • Cloud Router BGP IP: 169.254.154.190
      (Look for “IPSec Tunnel #1 Configuration file” -> “#3: Tunnel Interface Configuration” -> “Inside IP Addresses:” -> Customer Gateway)
    • BGP peer IP: 169.254.154.189
      (Look for “IPSec Tunnel #1 Configuration File ” -> “#3: Tunnel Interface Configuration” -> “Inside IP Addresses:” -> Virtual Private Gateway)
    위 과정은 CLI보다는 WEB Console에서 진행 필요.

     

    모든 과정이 정상적으로 종료되었다면 아래와 같이 Google Cloud 및 AWS Console 에서 확인.

     

     

     

    [성능테스트]

     

    Client Side : 10.0.3.231

     

    Server Side : 10.5.0.3

     

     

     

    Client & Server Side 양 서버에 iperf 설치.

     

    서버사이드(10.5.0.3) : iperf -s 

    클라이언트 사이드(10.0.3.231) : iperf -c 10.5.0.3 -p 5001

     

    평균 861Mbps 의 속도가 측정되었음. (24년 5월 31일 기준)

    (BGP 세션을 맺었음에도 통신이 안된다면, AWS의  Routing table, Security Group, NACL 을 확인하고, GCP에서 Firewall을 확인 바람)

     

     

     

    댓글