AWS Internet Gateway: Everything You Need to Know
AWS Internet gateways handle communication between your public subnets and the internet. If a resource in your public subnet has a public IPv4 address, it can reach the internet through an Internet gateway. This post covers what AWS Internet Gateway does, how to set one up, and some practical tips.
What is an AWS Internet Gateway?
An Internet Gateway is a VPC component that lets instances in your VPC talk to the internet. Think of it as a router that connects your VPC to the outside world.
The gateway handles NAT (Network Address Translation), which means instances in private subnets can reach the internet without needing their own public IP addresses.
Why do you need an Internet Gateway?
Without an internet gateway, your instances are isolated. They cannot reach external services, download packages, or do anything that requires internet access. If you want your VPC to communicate with the internet, you need a gateway in place.
How do you create an Internet Gateway?
You can create one through the AWS Management Console, CLI, or API. The console is the easiest way to get started:
- Log into your AWS account
- Go to Services → VPC
- Select “Internet Gateways” from the left menu
- Click “Create Internet Gateway”
- Give it a name and click “Create”
Done. Your gateway is ready to attach to a VPC.
How do you attach an Internet Gateway to Your VPC?
- Select your newly created gateway from the list
- Click “Attach to VPC”
- Pick your VPC from the dropdown
- Click “Attach”
Your VPC now has internet access through the gateway.
How do you delete an Internet Gateway?
Delete it through the console when you no longer need it:
- Select the gateway
- Click “Delete”
- Confirm with “Yes, Delete”
One thing to note: if the gateway is attached to a VPC, you must detach it first before deleting.
Best practices for using an Internet Gateway
A few things I recommend based on common setups:
- Use multiple subnets across availability zones so traffic can route efficiently
- Set up security groups to control what goes in and out of your subnets
- Use network ACLs on each subnet for an extra layer of traffic filtering
- Consider a load balancer in front of your web app to spread traffic evenly
NAT Gateway vs Internet Gateway
These serve different purposes:
- An Internet Gateway lets your VPC communicate with the internet. It’s the door out.
- A NAT Gateway lets instances in private subnets initiate outbound connections to the internet without receiving inbound traffic from it. It handles outgoing requests only.
How many VPCs can one Internet gateway support?
One Internet gateway attaches to one VPC. If you need redundancy, you can create multiple gateways and attach them to different VPCs. If one fails, traffic can route through another.
Benefits of using AWS Internet Gateway
- Secure connection between your VPC and the internet
- Supports both IPv4 and IPv6
- Low latency because traffic routes directly over AWS’s network backbone
- No hourly charges—you pay only for data transferred
- Full control over traffic using security groups and network ACLs
- Built-in high availability since the gateway itself is horizontally scaled
Enabling IPv6 communication
For IPv6, your VPC and subnet need an associated IPv6 CIDR block. Each instance then gets a globally unique IPv6 address automatically.
For IPv4, instances need a public IP or Elastic IP to receive inbound traffic. The gateway performs one-to-one NAT on behalf of your instance:
- When an instance sends traffic out, its private IP gets translated to its public IP
- When traffic comes in to that public IP, the gateway translates it back to the instance’s private IP
AWS Internet Gateway Pricing
Good news here: there is no charge for the gateway itself. You only pay for data transfer through it. The rates are:
- $0.045 per GB for the first 10 TB
- $0.04 per GB for 10-50 TB
- Even lower rates beyond 50 TB
Regional rates may vary slightly, and inter-region transfers have their own pricing.
Wrapping up
The Internet Gateway is a fundamental piece of AWS networking. It connects your VPC to the internet, handles NAT, and supports both IPv4 and IPv6. Follow the best practices above—use multiple subnets, lock down your security groups, and layer in network ACLs—and your setup will handle traffic reliably and securely.
Comments