</>Học Dev
Bài học

Tuần 4 - Ngày 5: VPN và Direct Connect Intro

Tuần 4 – Ngày 5

Tuần 4 - Ngày 5: VPN và Direct Connect Intro

Mục tiêu học tập

  • Hiểu Site-to-Site VPN architecture
  • Phân biệt VPN, Direct Connect, Client VPN
  • Nắm bandwidth, latency trade-offs
  • Biết khi nào dùng cái nào cho hybrid connectivity

1. Tổng quan Hybrid Connectivity

Use cases hybrid (on-prem + AWS)

  • Migration (lift-and-shift dần)
  • Data sync giữa on-prem DC và AWS
  • Burst compute lên AWS từ on-prem
  • DR (AWS làm DR cho on-prem)
  • Compliance (data sensitive ở on-prem, app ở AWS)

Options

OptionBandwidthLatencyCostEncryptedSetup time
Site-to-Site VPN~1.25 Gbps/tunnelVariable (internet)$Yes (IPsec)Phút
Direct Connect1, 10, 100 Gbps dedicatedStable, low$$$No (qua DX)Tuần - tháng
DX + VPNSame as DXSame as DX$$$YesTuần
Client VPNPer-userVariable$/user-hourYesPhút
Transit Gateway + DX/VPNAggregateSame$$Tùy

2. Site-to-Site VPN

Định nghĩa

Site-to-Site VPN = IPsec tunnel giữa on-prem router (Customer Gateway)AWS Virtual Private Gateway / Transit Gateway.

Components

On-PremisesAWSVPCCustomerVirtualGateway(CGW)IPsecPrivate(on-premrouter)2tunnelsGateway(VGW)PublicIP

Customer Gateway (CGW)

  • Đại diện cho on-prem device trong AWS
  • Public IP của router on-prem (hoặc NAT IP)
  • BGP ASN (nếu dùng dynamic routing)

Virtual Private Gateway (VGW)

  • AWS-side endpoint
  • Attached vào VPC
  • HA built-in (2 endpoints)

2 VPN Tunnels per Connection

  • Mỗi VPN connection có 2 tunnels ở 2 AZ khác nhau (HA)
  • On-prem router config cả 2 tunnels (active-active hoặc active-passive)

Routing options

  • Static routing: manual add routes
  • Dynamic routing (BGP): AWS và CGW exchange routes qua BGP

Bandwidth

  • Per tunnel: ~1.25 Gbps (single TCP flow)
  • Multi-tunnel ECMP: lên 5 Gbps total (Transit Gateway VPN attachment)
  • Đủ cho hầu hết workloads, không phù hợp high-volume data transfer

Setup time

  • Phút để setup AWS side
  • Phụ thuộc on-prem router config (thường vài giờ)

Cost

  • $0.05/hour per VPN connection
  • $0.05/GB data transfer (AWS → on-prem)

Use case

  • Quick hybrid setup
  • DR connection (backup cho DX)
  • Lower bandwidth needs (< 1 Gbps)

3. AWS Direct Connect (DX)

Định nghĩa

Direct Connect = dedicated physical fiber connection từ on-prem đến AWS, không qua internet.

Đặc điểm

  • Dedicated bandwidth: 1, 10, 100 Gbps
  • Lower latency: predictable, ổn định (không qua internet)
  • Lower data transfer cost (chargeable to "DX rates")
  • Setup time: tuần - tháng (cần install physical fiber)
  • Không encrypted by default (cần VPN over DX để encrypt)

Setup

  1. Order DX connection từ AWS Console
  2. Connect on-prem router → DX location (1 trong 100+ DX POPs toàn cầu)
  3. Hoặc dùng DX Partner (AT&T, Verizon, ...) nếu không có physical presence tại DX POP
  4. Configure Virtual Interface (VIF)

3 loại Virtual Interface (VIF)

VIF TypeUse case
Private VIFAccess VPC qua VGW (private resources)
Public VIFAccess AWS public services (S3, DynamoDB) qua DX
Transit VIFAccess multiple VPCs qua Transit Gateway

Direct Connect Gateway

  • Cho phép 1 DX connection access multiple VPCsmultiple Regions (cùng account hoặc cross-account)
  • Topology: CGW → DX → DX Gateway → VGW (multiple VPCs)

HA cho Direct Connect

  • Single DX connection: NOT HA (single physical link)
  • Best practice:
    • 2 DX connections2 DX locations khác nhau (max HA)
    • Hoặc 1 DX + VPN backup (cost optimization)

Cost

  • Port hour: $/hour per Gbps port (~$0.30/hour cho 1 Gbps)
  • Data transfer out: rẻ hơn internet egress (~$0.02/GB vs $0.09/GB)
  • Data transfer in: free

Use case

  • High-volume data transfer (TB/day)
  • Latency-sensitive apps (financial trading, real-time)
  • Compliance (regulated industries)
  • Predictable network performance

4. VPN over Direct Connect (Encrypted DX)

Pattern

  • DX provides bandwidth + low latency
  • VPN over DX adds encryption (IPsec)

Use case

  • HIPAA, PCI-DSS compliance requires encryption in-transit
  • Untrusted DX provider (rare)

5. AWS Client VPN

Định nghĩa

Client VPN = managed VPN service cho individual user devices (laptop, mobile) connect vào AWS VPC qua OpenVPN client.

Đặc điểm

  • TLS-based (OpenVPN)
  • Authentication:
    • Active Directory (qua AWS Directory Service)
    • Federated SAML (IdP)
    • Mutual TLS certificates
  • Authorization: per-user, per-network
  • Multi-platform clients: Windows, macOS, Linux

Architecture

UserLaptopOpenVPNClientVPNEndpointVPC(remoteworker)(intargetsubnet)Optional:peerVPC,on-prem

Use case

  • Remote employees access internal apps (alternative to corporate VPN)
  • Contractor access cụ thể VPCs
  • BYOD scenarios

Cost

  • $0.10/hour per association (endpoint to subnet)
  • $0.05/hour per active user connection

6. AWS Direct Connect Resiliency Models

AWS đề xuất 3 resilience patterns:

Maximum Resiliency (4 nines+)

  • 2 DX locations, each with 2 connections (4 total)
  • Tolerate location failure + connection failure
  • Cost cao nhất

High Resiliency (3 nines+)

  • 2 DX locations, 1 connection each (2 total)
  • Tolerate location failure
  • Cost vừa

Development & Test

  • 1 DX location, 1 connection
  • NOT HA — chấp nhận downtime nếu DX fail
    • Backup VPN
  • Cost thấp

7. AWS Global Accelerator vs DX

Direct ConnectGlobal Accelerator
Use caseOn-prem ↔ AWS hybridEnd-user → AWS app
ConnectionDedicated fiberAnycast IPs over internet (+ AWS backbone)
EncryptedNo (use VPN over)TLS-terminated at edge
Static IPN/AYes (2 anycast)

8. Hybrid Network Architecture Patterns

Pattern 1: Simple Site-to-Site VPN

On-premDCIPsecVPNVGWVPC
  • Quick start
  • Cost-effective
  • Adequate < 1 Gbps

Pattern 2: Direct Connect + VPN Backup

On-premDCDXVGWVPCVPNbackup
  • HA: DX primary, VPN failover
  • Lower cost than 2 DX

Pattern 3: DX + Transit Gateway (multiple VPCs)

On-premDXDXGatewayTransitGatewayVPC1,VPC2,VPC3...
  • Single connection access nhiều VPCs
  • Scalable

Pattern 4: Multi-Region DX

On-premDX(us-east-1)DXGTGWUSVPCsUSDX(eu-west-1)DXGTGWEUVPCsEU
  • Global presence
  • Region-specific connectivity

9. Network Performance Considerations

Latency

  • VPN over internet: ~50-100ms (variable)
  • DX from US East coast → us-east-1: ~5-10ms
  • Cross-Region: 50-200ms (depending)

Bandwidth

  • VPN: ~1.25 Gbps/tunnel
  • DX: 1, 10, 100 Gbps dedicated
  • VPC-to-VPC peering: no limit (within Region)

Data Transfer Pricing

  • AWS → Internet: $0.09/GB (us-east-1 base)
  • AWS → DX: $0.02-0.03/GB (cheaper!)
  • AWS → VPN: $0.05/GB

10. Decision Matrix

Hybridconnectivityneeded?Yes,<1Gbps,cantolerateinternetvariabilitySite-to-SiteVPNYes,>1GbpsORlatency-sensitiveORpredictableperfMissioncriticalDX+DXbackup(MaximumResiliency)StandardproductionDX+VPNbackupCost-consciousDXstandalone(acceptrisk)Individualusersremoteaccess?ClientVPNEncryptionoverDXrequired(HIPAA,etc.)?VPNoverDX

Câu hỏi ôn tập

  1. Site-to-Site VPN bandwidth per tunnel là bao nhiêu?

    Xem đáp án

    Mỗi tunnel Site-to-Site VPN tối đa 1.25 Gbps. Mỗi VPN connection có 2 tunnels (HA — nếu 1 tunnel fail, traffic chuyển sang tunnel kia). Để đạt throughput cao hơn, có thể dùng Accelerated Site-to-Site VPN (qua Global Accelerator) hoặc multiple VPN connections với ECMP trên Transit Gateway. Direct Connect cung cấp 1, 10, hoặc 100 Gbps.

  2. Direct Connect có encrypted by default không?

    Xem đáp án

    Không — Direct Connect là dedicated private network connection, nhưng không encrypted by default. Data in transit không encrypt. Để encrypt, dùng MACsec (Layer 2 encryption trên DX connection) hoặc overlay Site-to-Site VPN qua DX (IPSec encryption ở Layer 3). Với compliance requirements cần encryption in transit, phải implement thêm một trong hai layers.

  3. Direct Connect Gateway giải quyết vấn đề gì?

    Xem đáp án

    DX Gateway cho phép 1 Direct Connect connection access nhiều VPCs trong nhiều Regions (và nhiều AWS accounts). Không có DX Gateway: phải có riêng VIF cho mỗi VPC. Với DX Gateway: 1 Private VIF connect đến DX Gateway, gateway forward đến nhiều VGWs (Virtual Private Gateways) trong các VPCs khác nhau — hub-and-spoke model cho Direct Connect.

  4. VIF nào dùng để access S3 qua DX?

    Xem đáp án

    Public VIF (Public Virtual Interface). S3 là public AWS service với public IPs — cần Public VIF để access qua DX. Private VIF chỉ access resources trong VPC private IP space. Transit VIF dùng với Transit Gateway. Note: tuy gọi là "Public" VIF, traffic vẫn đi qua DX connection (not internet) — bảo mật hơn và không tính internet data transfer charge.

  5. Khác biệt giữa Client VPN và Site-to-Site VPN?

    Xem đáp án

    Site-to-Site VPN: kết nối network-to-network — on-premises network toàn bộ connect đến AWS VPC qua VGW và Customer Gateway. Dùng cho văn phòng hoặc datacenter cần kết nối thường xuyên đến AWS. Client VPN: kết nối individual device (laptop, remote worker) đến AWS VPC qua OpenVPN client. Mỗi user cần client software và certificate. Dùng cho remote workers cần access AWS resources.

Bài tập thực hành

  • Setup Site-to-Site VPN với CGW giả lập (pfSense trên EC2 ở VPC khác hoặc test environment)
  • Tạo Client VPN endpoint với mutual TLS, test connect từ laptop
  • Vẽ architecture diagram cho hybrid: on-prem DC connect 3 AWS VPCs khác Region
  • So sánh cost: VPN vs DX 1 Gbps cho 1 TB data/month

Tài liệu tham khảo chính thức


Tiếp theo: Route 53