Overview
Curated: · Written: · Reviewed:
Cloud Networking Fundamentals
In one line
A VPC is a routing and isolation boundary, and a subnet is an address range inside one availability zone. Routes decide where a packet goes; security groups and network ACLs decide whether it may pass. Reach for this model whenever you design or debug reachability for a cloud workload.
Key definitions
- VPC: logically isolated virtual network. Its router applies the route table associated with each subnet.
- Subnet: address range placed in one availability zone.
- Public subnet: a subnet whose route table sends 0.0.0.0/0 to an attached internet gateway. The name does not make it public.
- Security group: stateful filter on a network interface. Reply traffic for an allowed connection is tracked automatically.
- Network ACL: stateless filter at the subnet boundary. Inbound and outbound are evaluated separately.
- NAT gateway: lets private IPv4 workloads start outbound connections. It admits no unsolicited inbound traffic.
Formulas and complexity
AWS reserves five addresses per subnet, so a /24 leaves 251 usable addresses.
How it works
The route lookup selects the most specific matching prefix. The source filter and destination filter then apply, and the reply path needs its own route and filter.
- A route decides where traffic goes. Filters decide whether it passes.
- Internet reachability for IPv4 needs a 0.0.0.0/0 route to an IGW, a public address, and permitting filters. Missing any one of them fails the flow.
- Security groups track replies. Network ACLs need explicit rules for ephemeral return ports.
When to use and when not to
| Option | Use when | Avoid when |
|---|---|---|
| VPC peering | Two networks, few connections, non-overlapping CIDRs | You need transitive routing across many networks |
| Transit hub | Many VPCs plus on-premises, central policy or inspection | One pair of networks where a shared dependency is unwanted |
| NAT gateway | Private IPv4 workloads need outbound internet access | Anything must accept unsolicited inbound connections |
| S3 gateway endpoint | Private workloads need S3 without public egress | Traffic must pass through a firewall or egress proxy |
| Security group referencing another group | Workload IPs change, such as with autoscaling | The source is outside the VPC |
| Network ACL rules | Coarse subnet guardrail or emergency deny | Per-workload policy, which is hard to misorder and debug |
Traps interviewers probe
- Trusting the subnet name. Fix: check the effective route table for 0.0.0.0/0 to an IGW, then confirm a public IPv4 address on the ENI.
- Blocking ephemeral return ports in a network ACL. Replies leave on a high port, so a stateless outbound rule that allows only the service port drops them. Fix: allow the ephemeral range outbound, or rely on a stateful security group.
- Assuming peering is transitive. If A peers with B and B peers with C, A cannot reach C through B. Fix: peer directly, or use a transit hub.
- Peering overlapping CIDRs. Routes to an ambiguous destination cannot be resolved without translation or renumbering. Fix: plan non-overlapping blocks before connecting networks.
- Treating an endpoint policy as the whole authorization. The endpoint policy limits what can cross the endpoint, and the identity and resource policies still apply. Fix: check all three together when access is denied.
Interview tips
Open by naming the flow: source, destination, protocol, port, and direction. Then say which layer you check first. For a timeout, check name resolution, the forward route, both filters, the listener, and the return route, in that order.
Expect these follow-ups:
- Why does the return traffic fail when the network ACL seems to allow it? (Ephemeral ports on a stateless rule.)
- What if C needs to reach A through B? (Peering is not transitive. Use a transit hub.)
- How do you avoid one NAT gateway becoming a zone-wide failure? (Deploy one per zone and route each zone to its own gateway.)
- Why does the private DNS name resolve to the wrong address? (Check the zone association and the resolver path before touching routes.)
30-second outline: "I start from the flow and confirm the name resolves to the expected address. Then I check the forward route, the source and destination filters, and the listener. I check the return route and the ephemeral return path too, because a timeout is often a missing reply. Public reachability needs a route, a public address, and permitting filters together. I would also confirm failure domains per zone and that flow logs are on."
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.