INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

Topic lessonTopic: VPC: address and connectivity design

What is an internet gateway? VPC public routes and connectivity

An internet gateway (IGW) supports communication between a VPC and the internet. Attaching one does not publish every resource. Use a direct public-IPv4 EC2 example to separate gateway attachment, subnet routing, addressing, traffic controls and application listeners.

What you will learn

Explain the IGW’s role and identify missing requirements across routing, addressing, traffic controls and the application.

Prerequisite

Know VPCs, subnets, route tables and security-group permissions. The main example is direct IPv4 access to EC2, with comparisons to IPv6 and NAT. No AWS connection or configuration change is performed.

When a page fails, distinguish the stage before changing settings

Do not diagnose IGW or SG failure from “cannot connect” alone. Separate a failure before a confirmed HTTP response—the status and content returned for a Web request—from a response such as 503. DNS resolution finds an IP address for a name. DNS, TCP connection and TLS are different stages; TLS can fail after TCP connects. Keep the stage unknown when the evidence does not establish it.

A symptom selects the next evidence, not a guaranteed cause
ObservedEvidence to collect firstScope of this lesson
No confirmed HTTP response yetDNS result, destination/port and the failing TCP/TLS stage. A timeout alone does not locate the fault.For direct IPv4 to EC2, check the IGW, routes, address, controls and listener below.
An HTTP response such as 503 arrivedThe responding component and matching upstream/ALB/application records. The code alone is not an IGW diagnosis.Investigate response origin; this does not establish every request or dependency is healthy.
A matching log and arrival are unverifiedSubject, time, request identity, collection/retention and query scope. Separate missing records from non-arrival.Record the evidence gap instead of widening SG rules by guesswork.

The IGW provides a routing target and IPv4 address mapping

An IGW is a managed VPC component, not software you install on an EC2 instance. A subnet route table can select it for internet destinations. For IPv4, the IGW maps the instance’s private address to its public address. The address shown on the instance’s ordinary OS interface can therefore differ from the public IPv4 used by an external client.

Conceptual public-IPv4 request path; arrows show request direction, not configuration order
Conceptual public-IPv4 request path; arrows show request direction, not configuration order1: External client — A request to public IPv4; when using DNS, also verify the name resolves to the intended current destination. — Internet gateway. 2: Internet gateway — IPv4 destination mapping delivers traffic into the VPC; the arrow neither guarantees success nor bypasses controls. — EC2 and application12External clientInternet gatewayEC2 and applicationConceptual public-IPv4 request path; arrows show request direction, not configuration order1: External client — A request to public IPv4; when using DNS, also verify the name resolves to the intended current destination. — Internet gateway. 2: Internet gateway — IPv4 destination mapping delivers traffic into the VPC; the arrow neither guarantees success nor bypasses controls. — EC2 and application12External clientInternetgatewayEC2 andapplication
  1. External client → Internet gatewayA request to public IPv4; when using DNS, also verify the name resolves to the intended current destination.
  2. Internet gateway → EC2 and applicationIPv4 destination mapping delivers traffic into the VPC; the arrow neither guarantees success nor bypasses controls.
External client
Use the instance’s current public IPv4 and application port.
Internet gateway
Attached to the target VPC; maps public and private IPv4.
EC2 and application
Subnet routes, SG/NACL, OS and listener conditions must also match.

Check five layers: gateway, route, address, controls and listener

Direct IPv4 access from an external client to EC2
LayerRequired conditionWhat it does not prove
IGWAn IGW is attached to the correct VPCWhich subnets route to it
Route tableThe subnet’s effective table has a suitable IGW routeWhether the EC2 instance has public IPv4 or traffic permission
AddressThe external client uses the instance’s current public IPv4Whether the application port is reachable
Traffic controlsSG, NACL, OS and client controls permit the intended trafficWhether the application is listening
ApplicationA listener handles the request on the intended interface and portWhether other URLs or dependencies are healthy

A subnet with a direct route to an IGW is public. A typical IPv4 default route is 0.0.0.0/0 → IGW, but it does not override every other route: local VPC routes and more-specific destinations still matter. Public-subnet classification is separate from permission to expose a particular application.

Worked example: an IGW route does not replace public IPv4

Read this synthetic configuration; PUBLIC_IPV4 is a placeholder, not an actual address
SettingExample valueInterpretation
VPC / EC2 private IPv410.64.0.0/16 / 10.64.0.10The instance address is allocated from its subnet
Subnet / effective table10.64.0.0/24 / rt-ingressInspect the actual association, not its name
Routes10.64.0.0/16 → local; 0.0.0.0/0 → IGWAn IGW route exists
Public IPv4NoneThe external client cannot use this direct IPv4 method
SG inboundApplication port only from approved sourcesAn allow rule cannot replace missing public IPv4

Choose an option to see the result and explanation.

EC2 has only private IPv4. The IGW is attached and routing exists. Will widening the SG enable direct external IPv4 access?
Read the answer and reason

Answer: No: public IPv4 required by this method is missing · Routing and public IPv4 are separate requirements. First decide whether direct exposure belongs in the design; do not widen SG rules to compensate for a missing address.

Even with public IPv4, verify that the client is not using an old destination. Depending on the address allocation method, a stop/start can change an instance’s public IPv4. Match the current instance ID, address and DNS, and review authorization and cost before changing the exposure model.

Separate IPv4, IPv6 and NAT designs

Different connectivity methods still require traffic controls
MethodRole and prerequisitesImportant distinction
Direct IPv4 through IGWSuitable routing and resource public IPv4A public-looking VPC CIDR alone provides neither condition
IPv6 through IGWCompatible IPv6 addresses, IPv6 routes and controls0.0.0.0/0 is not an IPv6 route
Egress-only IGW for IPv6Supports internet connections initiated from insideIt is different from an ordinary IGW and IPv4 NAT gateway
IPv4 through public NAT gatewayTranslates the source of connections initiated insideIt is not a load balancer for unsolicited inbound application requests

Choose an option to see the result and explanation.

You configured 0.0.0.0/0 → IGW. Does that also configure the IPv6 default route?
Read the answer and reason

Answer: No: review IPv6 routes such as ::/0 separately · IPv4 and IPv6 match separate destination ranges. Also check IPv6 addressing, destination support and controls.

When access fails, collect evidence first

  1. Fix the connection method. Verify the resource, destination, port and source without mixing direct IPv4, IPv6, NAT or bastion assumptions.
  2. Check the IGW attachment and the subnet’s effective route table, including implicit main-table association.
  3. Match the required address family, current destination address and DNS result.
  4. Inspect SGs, both NACL directions, OS/client controls and the application listener. A timeout alone is not a diagnosis.
  5. Identify the missing condition before making an authorized change. Do not replace investigation with worldwide exposure or blanket restarts.

Fixed task: an SG allow does not establish a working return path

Separate the supplied evidence from what remains unknown
ItemSupplied condition
SymptomA TCP connection to the same destination reports a timeout; no HTTP response is confirmed.
Routing and addressFor this example, the target VPC IGW, effective subnet routing and current public IPv4 are stipulated correct.
Request-side conditionsThe intended SG permission, request-direction NACL conditions and TCP 443 application listener are stipulated satisfied.
Return-path candidateOn the EC2 subnet, the shown rules 100 and 110 are the only matching numbered egress rules. No earlier rule matches.
UnknownTLS certificate, HTTP response, business result and other clients/requests. A timeout message alone is not a unique diagnosis.

The request goes from client port 50000 to EC2 port 443; the reply goes from EC2 port 443 to client port 50000. The return path carries the server’s reply back to the client. A network ACL (NACL) allows or denies traffic entering or leaving a subnet, using the first matching rule in ascending number order. In this example the reply’s destination port is 50000, not 443. SG connection state does not turn a NACL denial into an allow.

Reply in this example: source 443 → client destination 50000
NACL numberMatching outbound conditionAction
100TCP / destination 192.0.2.10/32 / destination port 50000Deny
110TCP / destination 192.0.2.10/32 / destination port 50000Allow

Choose an option to see the result and explanation.

How do the two listed rules evaluate the reply?
Read the answer and reason

Answer: Rule 100 Deny matches first; SG state does not replace it · The stipulated return NACL condition fails. That does not establish every cause of a real symptom or TLS/application health.

Which next decision fits the request this design intends to allow?
Read the answer and reason

Answer: Review intent and impact, change only the required return-rule scope, then retest · Have the owner review order, scope and required ports, then recheck both permitted and intentionally denied traffic.

Build an investigation and verification record
StepWhat to record for this task
Candidate causeDo not diagnose from the timeout alone. Correlate current EC2-subnet egress NACL rules with the reply destination port; the fixed facts select rule 100 Deny.
Missing evidenceIn a real investigation, verify subject, time, current rules and both directions. Keep TLS and application results separately unverified.
Minimal proposed responseCheck whether denial is intentional, confirm design intent and obtain authorization. Review only the needed return scope and first matching rule; record effects on other resources sharing the NACL and a reversal plan.
Retest equivalent conditionsUse the same source, destination, method and application port, while checking the current ephemeral port. Verify expected HTTP/business behavior and requests that must remain denied.
Completion and unknownsA proposal alone is not a completed fix. Record actual results and unresolved evidence separately; this lesson performs no real repair.

Choose the next investigation from the evidence

Check, then explain in your own words

  1. Explain why IGW attachment and subnet routing are separate settings.
  2. Separate five checks for an unreachable EC2 instance in a public subnet.
  3. Distinguish direct IPv4, NAT and egress-only IPv6 approaches.
Check your understanding: Does attaching an IGW publish every EC2 instance in the VPC?

No. Check each subnet’s routes, addressing, controls and application separately.

The IGW is one component. Separating public routing from resource-specific reachability avoids unnecessary changes to exposure or permissions.

Sources and conditions checked

The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.