Tạo EC2 Instance

Triển khai EC2 Instance cho Customer Gateway

ℹ️ Tổng quan

  • Trong phần này, chúng ta sẽ triển khai EC2 instance để làm Customer Gateway
  • Instance sẽ được đặt trong public subnet của VPC ASG VPN
  • Cần cấu hình security group phù hợp cho VPN và SSH access

Tạo Security Group

  1. Truy cập VPC Dashboard
    • Chọn Security Groups
    • Click Create security group

Create VPC

  1. Cấu hình Security Group
    • Name: Nhập VPN Public-SG
    • Description: Nhập Allow IPSec, SSH and Ping for servers in public subnet
    • VPC: Chọn ASG VPN

Create VPC

🔒 Security Rules - Inbound Thêm các inbound rules sau để hỗ trợ VPN và quản lý:

Type Protocol Port Source Purpose
SSH TCP 22 My IP Quản lý từ xa
ICMP ICMP All Anywhere Ping testing
Custom UDP UDP 500 Anywhere IKE (IPsec key exchange)
Custom UDP UDP 4500 Anywhere NAT-T (IPsec NAT traversal)

💡 Giải thích Ports:

  • Port 500 (UDP): IKE (Internet Key Exchange) - Thiết lập VPN tunnel
  • Port 4500 (UDP): NAT-T - IPsec qua NAT devices
  • ICMP: Cho phép ping để test connectivity

Create VPC

  1. Kiểm tra outbound rules và click Create security group

Create VPC

Triển khai EC2 Instance

  1. Truy cập EC2 Dashboard
    • Chọn Instances
    • Click Launch instances

Create VPC

  1. Cấu hình Instance

    • Name: Nhập Customer Gateway instance
    • AMI: Chọn Amazon Linux 2023
    • Instance type: t3.micro
    • Key pair: Chọn aws-keypair

    💡 Lựa chọn Instance Type: t3.micro đủ cho VPN gateway trong lab, production nên dùng t3.small hoặc lớn hơn.

Create VPC Create VPC Create VPC

  1. Network Settings
    • VPC: Chọn ASG VPN
    • Subnet: Chọn VPN Public
    • Auto-assign public IP: Enable (Bắt buộc cho VPN)
    • Security group: Chọn VPN Public-SG

Create VPC

  1. Review và Launch Instance
    • Kiểm tra lại cấu hình
    • Click Launch instance

Create VPC

Create VPC


🏗️ Vai trò Customer Gateway

Customer Gateway EC2 Instance
├── Libreswan/OpenSwan (IPsec software)
├── Public IP (VPN endpoint)
├── Private IP (10.11.1.x)
└── Routing configuration

⚠️ Lưu ý Quan trọng

  • ✅ Instance PHẢI có public IP để thiết lập VPN tunnel
  • ✅ Security group phải mở ports 500 và 4500 (UDP) cho IPsec
  • ✅ Sẽ cần disable source/destination check (bước tiếp theo)
  • ✅ Lưu lại Public IP để cấu hình Customer Gateway

💡 Tiếp theo: Sau khi instance running, chúng ta sẽ:

  1. Disable source/destination check
  2. Cài đặt Libreswan
  3. Cấu hình IPsec tunnels

✅ Hoàn thành: Customer Gateway EC2 đã sẵn sàng cho cấu hình VPN!