Skip to content

Lesson 06 β€” Internet Gateway & NAT Gateway

Learning Path

☁️ Phase 2 – AWS Cloud Security

πŸ“˜ Module 04 – Amazon VPC & Network Security


By the end of this lesson, you will be able to:

  • Understand Internet Gateways (IGW).
  • Understand NAT Gateways.
  • Differentiate inbound and outbound Internet traffic.
  • Configure Internet connectivity.
  • Build Internet Gateway and NAT Gateway using AWS Console.
  • Configure routing using Route Tables.
  • Verify Internet connectivity.
  • Apply enterprise networking best practices.

πŸ“š Lesson Information

Estimated Time: 120 Minutes

Difficulty: Beginner

Prerequisites: Lesson 05 – Route Tables

Hands-on Lab: Yes


Every enterprise application has different Internet connectivity requirements.

For example:

Resource Internet Required?
Public Website βœ… Yes
Application Server βœ… Outbound Only
Database ❌ No
Bastion Host βœ… Yes
Internal API ❌ No

Instead of exposing every server to the Internet, AWS provides two networking components:

  • Internet Gateway (IGW)
  • NAT Gateway

These services allow organisations to securely control inbound and outbound Internet traffic.


CloudNova has deployed:

  • Public Load Balancer
  • Application Servers
  • Database Servers

Requirements:

  • Customers must access the website.
  • Application servers must download software updates.
  • Databases must never communicate directly with the Internet.

The Cloud Security Team decides to use:

  • Internet Gateway
  • NAT Gateway

An Internet Gateway (IGW) is a highly available AWS-managed component that enables communication between your VPC and the Internet.

It allows:

  • Incoming Internet traffic
  • Outgoing Internet traffic

An Internet Gateway is attached to a VPC.

Without an Internet Gateway, resources inside the VPC cannot communicate directly with the Internet.


Internet
↓
Internet Gateway
↓
Public Route Table
↓
Public Subnet
↓
Application Load Balancer
↓
EC2

Only resources in Public Subnets can use the Internet Gateway.


A NAT (Network Address Translation) Gateway allows resources in Private Subnets to initiate outbound Internet connections while preventing inbound Internet access.

Typical uses include:

  • Operating system updates
  • Installing software packages
  • Downloading application dependencies
  • Accessing AWS APIs
  • Connecting to external services

Users on the Internet cannot initiate connections to instances behind a NAT Gateway.


Private EC2
↓
Private Route Table
↓
NAT Gateway
↓
Internet Gateway
↓
Internet

Notice:

Internet traffic always passes through the Internet Gateway because the NAT Gateway itself resides in a Public Subnet.


Internet Gateway NAT Gateway
Public Internet access Private outbound access
Supports inbound & outbound traffic Outbound traffic only
Attached directly to VPC Deployed inside Public Subnet
Used by Public Subnets Used by Private Subnets
No Elastic IP required Requires an Elastic IP

Internet
β”‚
Internet Gateway
β”‚
────────────────────────
Public Subnet
β”‚
Application Load Balancer
β”‚
Bastion Host
β”‚
NAT Gateway
────────────────────────
β”‚
Private App Subnet
β”‚
EC2
Containers
────────────────────────
β”‚
Private Database Subnet
β”‚
Amazon RDS

This architecture follows AWS Well-Architected best practices.


πŸ›  Lab 01 β€” Create an Internet Gateway (AWS Console)

Section titled β€œπŸ›  Lab 01 β€” Create an Internet Gateway (AWS Console)”

Open

AWS Console
↓
VPC

Navigate to

Internet Gateways
↓
Create Internet Gateway

Configure

Setting Value
Name CloudNova-IGW

Click

Create Internet Gateway

Attach Internet Gateway

Select:

CloudNova-IGW
↓
Actions
↓
Attach to VPC

Choose

CloudNova-VPC

Click

Attach

Navigate to:

Route Tables
↓
Public-RT
↓
Routes
↓
Edit Routes

Ensure the following route exists:

Destination Target
10.10.0.0/16 Local
0.0.0.0/0 Internet Gateway

Save Changes.


Navigate to

VPC
↓
Elastic IP Addresses
↓
Allocate Elastic IP

Accept defaults.

Click

Allocate

Record the Elastic IP Allocation ID.


Navigate to

VPC
↓
NAT Gateways
↓
Create NAT Gateway

Configure:

Setting Value
Name CloudNova-NAT
Subnet Public-Subnet-A
Elastic IP Select Allocated Elastic IP

Click

Create NAT Gateway

Wait until the status changes to:

Available

This may take several minutes.


Open:

Route Tables
↓
Private-RT
↓
Routes
↓
Edit Routes

Add:

Destination Target
10.10.0.0/16 Local
0.0.0.0/0 CloudNova-NAT

Save Changes.

Now Private Subnets can access the Internet without being publicly accessible.


Terminal window
aws ec2 describe-internet-gateways

Terminal window
aws ec2 create-internet-gateway

Terminal window
aws ec2 create-tags \
--resources igw-xxxxxxxx \
--tags Key=Name,Value=CloudNova-IGW

Terminal window
aws ec2 attach-internet-gateway \
--internet-gateway-id igw-xxxxxxxx \
--vpc-id vpc-xxxxxxxx

Terminal window
aws ec2 allocate-address \
--domain vpc

Record:

AllocationId

Terminal window
aws ec2 create-nat-gateway \
--subnet-id subnet-public \
--allocation-id eipalloc-xxxxxxxx

Terminal window
aws ec2 describe-nat-gateways

Terminal window
aws ec2 create-route \
--route-table-id rtb-private \
--destination-cidr-block 0.0.0.0/0 \
--nat-gateway-id nat-xxxxxxxx

Terminal window
aws ec2 describe-route-tables

Your environment should look like this.

Internet
↓
Internet Gateway
↓
Public Route Table
↓
Public Subnet
↓
Application Load Balancer
↓
NAT Gateway
↓
Private Route Table
↓
Private App Subnet
↓
Private Database Subnet

Verify:

βœ… Internet Gateway attached

βœ… Elastic IP allocated

βœ… NAT Gateway status = Available

βœ… Public Route Table points to IGW

βœ… Private Route Table points to NAT Gateway


Launch:

  • One EC2 instance in Public-Subnet-A
  • One EC2 instance in Private-App-A

Test:

From the Public EC2:

Terminal window
ping google.com

Expected:

Replies received

From the Private EC2:

Terminal window
ping google.com

or

Terminal window
curl https://aws.amazon.com

Expected:

Outbound Internet access works through NAT Gateway.

The Private EC2 should not have a Public IPv4 address.


No Internet from Public EC2.

Check:

  • Internet Gateway attached?
  • Public Route Table configured?
  • Security Group outbound rule?
  • Public IPv4 assigned?

Private EC2 cannot access Internet.

Check:

  • NAT Gateway status = Available.
  • NAT Gateway is in a Public Subnet.
  • Private Route Table points to NAT Gateway.
  • Elastic IP attached.
  • Outbound Security Group rules.

NAT Gateway creation fails.

Verify:

  • Elastic IP allocated.
  • Public Subnet selected.
  • Internet Gateway attached to VPC.

CloudNova standards:

  • Never place a NAT Gateway in a Private Subnet.
  • Deploy one NAT Gateway per Availability Zone for production workloads.
  • Monitor NAT Gateway costs using AWS Cost Explorer.
  • Use VPC Endpoints for AWS services where possible to reduce NAT traffic.
  • Keep databases isolated in Private Subnets.
  • Review Route Tables during security assessments.

❌ Forgetting to attach the Internet Gateway.

❌ Creating the NAT Gateway in a Private Subnet.

❌ Forgetting the Elastic IP.

❌ Pointing the Private Route Table directly to the Internet Gateway.

❌ Deploying databases in Public Subnets.

❌ Assuming the NAT Gateway allows inbound Internet traffic.


Using your AWS account:

Create:

  • CloudNova-IGW
  • Elastic IP
  • CloudNova-NAT

Configure:

  • Attach IGW to CloudNova-VPC.
  • Create NAT Gateway in Public-Subnet-A.
  • Update Public Route Table.
  • Update Private Route Table.

Verify:

  • Public EC2 has Internet access.
  • Private EC2 has outbound Internet access.
  • Private EC2 does not have a Public IPv4 address.

Take screenshots of:

  • Internet Gateway
  • NAT Gateway
  • Elastic IP
  • Route Tables
  • EC2 networking
  • AWS CLI output

  1. What is an Internet Gateway?

  2. What is a NAT Gateway?

  3. Why must a NAT Gateway be placed in a Public Subnet?

  4. Which AWS resource requires an Elastic IP?

  5. Can a Private EC2 instance receive inbound Internet traffic through a NAT Gateway?

  6. Which Route Table should contain the Internet Gateway route?

  7. Which Route Table should contain the NAT Gateway route?

  8. Why do enterprises deploy one NAT Gateway per Availability Zone?

  9. What are the security benefits of Private Subnets?

  10. How do Internet Gateways and NAT Gateways work together?


After completing this lesson, you should understand:

  • An Internet Gateway connects an Amazon VPC to the public Internet.
  • A NAT Gateway allows Private Subnets to initiate outbound Internet connections without exposing resources to inbound Internet traffic.
  • Public Route Tables use an Internet Gateway, while Private Route Tables use a NAT Gateway.
  • NAT Gateways require an Elastic IP address and must be deployed in a Public Subnet.
  • Designing Internet connectivity correctly is a fundamental responsibility of Cloud Security Engineers and Cloud Architects.

➑️ Lesson 07 β€” Security Groups