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

Tuần 4 - Ngày 4: VPN và Hybrid Connectivity

Tuần 4 – Ngày 4

Tuần 4 - Ngày 4: VPN và Hybrid Connectivity

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

  • Hiểu các VPN options trên AWS
  • Nắm vững Site-to-Site VPN configuration
  • Biết cách thiết kế hybrid architectures

1. AWS VPN Options

Types of VPN

AWSVPNOPTIONS1.AWSSite-to-SiteVPNConnecton-premisesnetworktoVPCEncryptedIPsectunnelsoverinternetManagedbyAWS2.AWSClientVPNRemoteaccessforindividualusersOpenVPN-basedclientManagedelasticendpoint3.AWSVPNCloudHubConnectmultipleon-premisessitesHub-and-spokeviaAWSUsesVirtualPrivateGateway

2. Site-to-Site VPN Components

Architecture

On-PremisesNetworkCustomerGateway(CGW)(YourVPNdevice)IP:203.0.113.1IPsecTunnels(2tunnelsforHA)AWSVirtualPrivateGateway(VGW)ORTransitGatewayTunnel1:169.254.x.x/30Tunnel2:169.254.y.y/30VPC10.0.0.0/16

Customer Gateway (CGW)

Requirements for CGW device:
- IKEv1 or IKEv2 support
- IPsec support
- BGP (optional but recommended)
- Static public IP address

Supported devices:
- Cisco (ASA, IOS, IOS-XE)
- Juniper
- Palo Alto
- Fortinet
- pfSense
- Many others...

3. VPN Tunnel Configuration

Two Tunnels for HA

VPNConnectionTunnel1(Primary-AZ-a)OutsideIP:35.x.x.x(AWSendpoint)InsideIP:169.254.10.0/30Pre-sharedKey:*****Status:UPTunnel2(Secondary-AZ-b)OutsideIP:52.x.x.x(AWSendpoint)InsideIP:169.254.20.0/30Pre-sharedKey:*****Status:UPBestPractice:ConfigurebothtunnelsonCGW

Routing Options

1. Static Routing:
   - Manually specify on-premises CIDR
   - Simple but no automatic failover

2. Dynamic Routing (BGP):
   - Exchange routes automatically
   - Faster failover
   - Recommended for production

BGP Configuration:
- AWS ASN: 64512 (default) or custom
- Customer ASN: Your ASN
- BGP over tunnel inside IPs

4. Accelerated Site-to-Site VPN

With AWS Global Accelerator

WithoutAcceleration:InternetPathOn-PremisesAWSVPNVariablelatencyEndpointWithAcceleration:On-PremisesNearestEdgeAWSVPNLocationEndpointAWSBackbone(Moreconsistent)Benefits:-Lowerlatency-Lessjitter-Moreconsistentperformance-UsesAWSglobalnetwork

5. AWS Client VPN

Architecture

AWSClientVPNClientVPNEndpoint(ManagedbyAWS)Authentication:-ActiveDirectory-SAML(Okta,AzureAD)-Mutualauthentication(certificates)VPCOn-PremisesResources(viaVGW)OpenVPNclientRemoteUser(Laptop)

Use Cases

  • Remote worker access
  • Contractor access
  • Emergency access during disaster

6. VPN CloudHub

Hub-and-Spoke Connectivity

VirtualPrivateGateway(VGW)CGW1CGW2CGW3SiteASiteBSiteC192.168.1.0/24192.168.2.0/24192.168.3.0/24Trafficflow:-SiteAAWSVPC:Direct-SiteASiteB:ViaVGW(hub)-AllsitesusesameVGWashub

7. Hybrid Architecture Patterns

Pattern 1: VPN Only

Best for:
- Getting started with hybrid
- Lower bandwidth requirements (<1.25 Gbps)
- Quick setup needed
- Backup for Direct Connect

Limitations:
- Performance varies with internet
- Max ~1.25 Gbps per tunnel

Pattern 2: Direct Connect + VPN Backup

On-PremisesRouterDirectConnect(Primary)Site-to-SiteVPN(Backup)Failover:1.DXfails2.BGPdetectsfailure(BFDifenabled)3.TrafficshiftstoVPN4.WhenDXrecovers,trafficreturns

Pattern 3: Dual Direct Connect

On-PremisesRouter1DXLocation1Router2DXLocation2Highestavailabilitybutmostexpensive

8. VPN Performance Tuning

Bandwidth Optimization

SingleVPN:1.25GbpspertunnelWithECMP(TransitGateway):MultipleVPNconnections+ECMPVPN1:1.25GbpsVPN2:1.25GbpsTransitGatewayVPN3:1.25Gbps(ECMPenabled)Total:3.75GbpsCanscaleupto50Gbps

Latency Optimization

1. Use Accelerated Site-to-Site VPN
2. Enable Dead Peer Detection (DPD)
3. Configure BFD for fast failover
4. Use BGP for dynamic routing

9. Câu hỏi ôn tập

  1. Site-to-Site VPN có bao nhiêu tunnels?

    Xem đáp án

    2 tunnels per VPN connection — active-active (BGP) hoặc active-standby. Hai tunnels terminate ở 2 endpoints AWS khác nhau (different AZ) để HA. Mỗi tunnel max 1.25 Gbps. Cả hai tunnels nên được config trên Customer Gateway device. Nếu chỉ dùng 1 tunnel: không có redundancy phía AWS side. BGP ưu tiên tunnel với best path; non-BGP (static routing) thường dùng active-standby.

  2. Accelerated VPN khác VPN thường như thế nào?

    Xem đáp án

    Accelerated VPN (Accelerated Site-to-Site VPN) route traffic qua AWS Global Accelerator anycast IPs — traffic vào AWS network tại Edge Location gần nhất, rồi traverse AWS backbone. Giảm latency và jitter so với routing toàn bộ qua public internet. Phù hợp cho: global on-premises offices cách xa AWS Region, latency-sensitive applications, gaming/VoIP qua VPN. Chi phí thêm Global Accelerator fee (~$0.025/giờ + data fees).

  3. Client VPN dùng authentication methods nào?

    Xem đáp án

    3 methods: (1) Active Directory (AWS Managed Microsoft AD hoặc AD Connector — authenticate bằng corporate credentials), (2) Certificate-based (mutual TLS — client và server đều có certificates từ CA), (3) SAML-based federated authentication (Okta, Azure AD, Ping Identity). Có thể kết hợp AD + Certificate. Client VPN dùng OpenVPN protocol — compatible với nhiều VPN clients (AWS VPN Client, OpenVPN Connect).

  4. VPN CloudHub dùng để làm gì?

    Xem đáp án

    VPN CloudHub cho phép nhiều on-premises sites giao tiếp với nhau qua AWS như một hub. Mỗi site có Site-to-Site VPN kết nối đến cùng VGW (Virtual Private Gateway). Traffic từ Site A → AWS VGW → Site B — AWS đóng vai trò trung gian. Phù hợp cho công ty có nhiều văn phòng cần kết nối với nhau mà không cần MPLS network riêng. Không phải service riêng — chỉ là architecture pattern với existing VPN.

  5. Làm sao để tăng VPN bandwidth?

    Xem đáp án

    (1) Multiple VPN connections + ECMP qua Transit Gateway — nhiều connections parallel, aggregate bandwidth. (2) Accelerated VPN giảm latency nhưng không tăng throughput per tunnel. (3) Nếu cần > 10 Gbps: migrate sang Direct Connect (1G, 10G, hoặc 100G). Với TGW + ECMP: N VPN connections × 2 tunnels/connection × 1.25 Gbps/tunnel = N × 2.5 Gbps. Cần Customer Gateway device hỗ trợ ECMP và BGP.

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

  • Create Site-to-Site VPN connection
  • Download và review VPN configuration
  • Setup Client VPN endpoint
  • Test failover scenarios

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


Ngày tiếp theo: Route 53 Advanced