Tạo NAT Gateway

Tạo NAT Gateway

ℹ️ Tổng quan

  • NAT Gateway cho phép các instances trong private subnet kết nối ra internet
  • Đảm bảo kết nối một chiều từ trong ra ngoài, tăng tính bảo mật
  • Cần có Elastic IP và đặt NAT Gateway trong public subnet

Tạo Elastic IP Address

  1. Truy cập EC2 Dashboard
    • Chọn Elastic IPs từ menu bên trái
    • Click Allocate Elastic IP address

Create VPC

  1. Cấu hình Elastic IP
    • Public IPv4 address pool: Chọn Amazon’s pool of IPv4 addresses
    • Click Allocate

Create VPC

  1. Xác nhận tạo thành công Elastic IP

Create VPC

Triển khai NAT Gateway

  1. Truy cập VPC Dashboard
    • Chọn NAT Gateways
    • Click Create NAT gateway

Create VPC

  1. Cấu hình NAT Gateway
    • Name: Nhập NAT gateway
    • Subnet: Chọn Public subnet 2
    • Connectivity type: Chọn Public
    • Elastic IP allocation ID: Chọn Elastic IP vừa tạo

Create VPC

  1. Click Create NAT gateway

Create VPC

  1. Xác nhận tạo thành công NAT Gateway

Create VPC

Cấu hình Route Table cho Private Subnet

  1. Trong VPC Dashboard
    • Chọn Route Tables
    • Click Create route table

Create VPC

  1. Thiết lập Route Table
    • Name: Nhập Route table - Private
    • VPC: Chọn VPC ASG
    • Click Create route table

Create VPC

  1. Xác nhận tạo thành công Route Table

Create VPC

💡 Cấu hình Subnet Associations

  1. Trong Route Table mới tạo
    • Chọn tab Subnet Associations
    • Click Edit subnet associations

Create VPC

  1. Liên kết Private Subnets
    • Chọn cả 2 private subnet
    • Click Save associations

Create VPC

  1. Cấu hình Routes
    • Chọn tab Routes
    • Click Edit routes

Create VPC

  1. Thêm Route cho Internet Access
    • Click Add route
    • Destination: Nhập 0.0.0.0/0
    • Target: Chọn NAT Gateway
    • Click Save changes

Create VPC

  1. Xác nhận cấu hình Routes

Create VPC

⚠️ Kiểm tra Kết nối

  1. Thực hiện ping test từ EC2 Private Instance