Chapter 15: Amazon VPC — Subnets, Route Tables, NACL, NAT Gateway and Bastion Host
15.5 Internet gateway
In short: An internet gateway (IGW) is a horizontally scaled, redundant and highly available VPC component that connects your VPC to the internet.
The society's main gate – without it nobody comes in and nobody goes out. The Internet Gateway (IGW) is exactly that main gate. But note: putting up a gate does not give every wing a road – the road has to be written on the direction board. That is in the next lesson.
Society चा main gate – हा नसेल तर कोणी आत येत नाही आणि कोणी बाहेर जात नाही. Internet Gateway (IGW) हाच main gate. पण लक्ष द्या: gate लावला म्हणून प्रत्येक wing ला रस्ता मिळत नाही – direction board वर रस्ता लिहावा लागतो. ते पुढच्या lesson मध्ये.
Society का main gate – यह न हो तो कोई अंदर नहीं आता और कोई बाहर नहीं जाता. Internet Gateway (IGW) यही main gate है. पर ध्यान दो: gate लगाने से हर wing को रास्ता नहीं मिलता – direction board पर रास्ता लिखना पड़ता है. वह अगले lesson में.
An internet gateway (IGW) is a horizontally scaled, redundant and highly available VPC component that connects your VPC to the internet. For an instance with a public IPv4 address, it translates between the instance's private IP and its public IP (one-to-one NAT). A VPC can have one internet gateway attached at a time, and the gateway itself has no charge (public IPv4 addresses are charged separately).
An instance can talk to the internet only when all four of these are true:
| # | Condition | Where |
|---|---|---|
| 1 | An internet gateway is attached to the VPC | VPC → Internet gateways |
| 2 | The subnet's route table has 0.0.0.0/0 → igw-... |
VPC → Route tables |
| 3 | The instance has a public IPv4 or an Elastic IP | EC2 → Instances |
| 4 | The security group and the network ACL allow the traffic | EC2 / VPC |
Create and attach the internet gateway
- VPC → Internet gateways → Create internet gateway → Name tag
society-igw→ Create internet gateway. - On the new gateway: Actions → Attach to VPC → choose
society-vpc→ Attach internet gateway. - The State changes from Detached to Attached.
aws ec2 create-internet-gateway --tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=society-igw}]'
aws ec2 attach-internet-gateway --internet-gateway-id igw-0123456789abcdef0 --vpc-id vpc-0123456789abcdef0
Ravindra Bagale's Tip
Many students create the IGW and forget Attach to VPC – the State stays Detached, and then it feels like "I did everything but there is no internet". As soon as you create the IGW, attach it and check that the State is Attached. Very simple, but people get it wrong a lot.
Ravindra Bagale's Tip – मराठी
बरेच students IGW बनवतात आणि Attach to VPC करायला विसरतात – State Detached च राहतो आणि मग "सगळं केलं तरी internet नाही" असं वाटतं. IGW बनवला की लगेच attach करा आणि State Attached आहे का ते बघा. एकदम simple, पण खूप वेळा चुकतात.
Ravindra Bagale's Tip – हिंदी
बहुत से students IGW बनाते हैं और Attach to VPC करना भूल जाते हैं – State Detached ही रहता है और फिर लगता है "सब किया फिर भी internet नहीं". IGW बनाते ही attach करो और देखो कि State Attached है या नहीं. एकदम simple, पर बहुत बार गलती होती है.
Lab
Chala, create society-igw and attach it to society-vpc. Then try to attach a second internet gateway to the same VPC and read the error: one VPC takes only one internet gateway at a time. Delete the extra gateway.
Step-by-step guide