Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Chapter 15: Amazon VPC — Subnets, Route Tables, NACL, NAT Gateway and Bastion Host

Come on, friends, now the most important chapter of AWS networking – VPC. Until now we launched every server in the default VPC, and AWS had already built the network for us. Now we build our own network. Picture a housing society: the whole society is the VPC, the wings are subnets, the main gate is the Internet Gateway, the security guard at the wing entrance is the NACL, each flat's lock is the security group, and the direction board near the gate is the route table. At the end we do a real 3-tier project – Nginx, PHP and MySQL in three different subnets. Don't worry, you will get it, slowly slowly you will get it.

In this chapter

  • Default VPC vs custom VPC
  • CIDR blocks for VPCs and subnets
  • Public and private subnets
  • Internet gateway and route tables
  • NACL rules and blocking an IP
  • Security group vs NACL
  • Bastion host and NAT gateway
  • A 3-tier Nginx, PHP, MySQL project

This chapter builds on Chapter 1 (IP addresses, CIDR and NAT), Chapter 5 (EC2 and security groups) and Chapter 10 (PHP with MySQL). The expanded overview uses offline address and traffic models. For a later authorized cloud lab, identify the correct account, Region, resources, pricing and cleanup plan before making changes.

Concepts in this chapter

  1. 15.1What is a VPC? Default VPC vs custom VPC
  2. 15.2How to create a custom VPC and choose its CIDR block
  3. 15.3Subnets: default and custom subnets, CIDR and limits
  4. 15.4Why do we need subnets? The 3-tier layout
  5. 15.5Internet gateway
  6. 15.6Route tables: public and private subnets
  7. 15.7Network ACL: inbound and outbound rules, rule numbers and blocking an IP
  8. 15.8Security group vs NACL
  9. 15.9Bastion host (jump server) and NAT gateway
  10. 15.10Project: build the 3-tier network and launch the servers
  11. 15.11Project: MySQL, PHP-FPM and Nginx on three tiers
  12. 15.12Project: test every hop, troubleshoot and clean up

Review and practice

  1. ★Common Mistakes I See Students Make
  2. ★Interview Questions
  3. ★Practice Questions and Lab Exercises

Follow three connections to a saved registration

Follow three connections to a saved registrationBrowser to entryPublic name and HTTPS listenerEntry to applicationA separate private connectionApplication to databasePrivate path and database identitySaved resultRead back the accepted record
Read all steps
  1. Browser to entry

    The browser reaches the intended public entry through the configured address, route and permissions. Loading this first response does not prove that a later registration can reach its database.

  2. Entry to application

    The entry connects to the configured application listener. Verify this connection independently, including its actual source, target, route and service port.

  3. Application to database

    The application opens its own database connection and authenticates. A network permission does not grant database privileges or make the database process listen.

  4. Saved result

    After the intended commit, compare the response with the saved registration. Routing, permissions and listeners are prerequisites; the useful application result needs its own check.

1. Give each part of the workshop the connections it needs

A workshop website has a public timetable, an application that accepts registrations and a database that stores them. Students need to reach the website. They do not need to connect directly to the database or open an administrator's shell. The application needs a database connection, while an administrator needs a controlled maintenance path. These different needs are the starting point for designing the network.

Amazon Virtual Private Cloud, or VPC, provides a logically isolated virtual network for supported AWS resources. You choose address ranges and arrange subnets, routing and access controls around the workload. A VPC is a regional resource, while each subnet belongs to one Availability Zone. It is not a container holding every AWS service: some services are accessed through their service endpoints. See the VPC overview.

Think first about conversations rather than boxes. A student's browser talks to the web entry. The web entry makes a separate connection to the application. The application makes another connection to the database. Each conversation has a source, destination, protocol and purpose. A working first conversation does not prove the next one works. This is why a timetable can load even when submitting its registration form fails.

For each connection, keep three questions separate: is there a suitable network path, do the relevant controls permit the traffic, and is the intended service actually listening and able to respond? A route does not grant application permission. A security-group rule does not install software. A running database process does not create a missing route. Reliable troubleshooting depends on keeping these responsibilities clear.

This overview develops the design using fictional addresses and offline exercises. It introduces the reasoning needed for the later three-tier project without creating a VPC or changing a live network. The diagrams and models simplify the environment deliberately; their assumptions are explained so you can recognize what must be checked separately in a real deployment.

2. Plan address ranges before assigning individual machines

An IP address identifies an interface's address within the relevant network context. A CIDR block describes a range using a network address and a prefix length. In IPv4 there are thirty-two address bits. A prefix of twenty-four leaves eight bits for addresses in that range, giving two to the power of eight, or 256 total addresses. A larger prefix number describes a smaller range.

Our fictional VPC uses 10.44.0.0/16. We reserve 10.44.10.0/24 for the web entry, 10.44.20.0/24 for application resources and 10.44.30.0/24 for the database example. All three ranges fit inside the parent and do not overlap. Their names describe intended roles; their actual routing and controls determine behavior.

For ordinary AWS IPv4 subnets, the first four and last address are reserved. Thus a standard slash-twenty-four subnet has 251 addresses available for assignment before accounting for actual resource use. Subnet ranges in a VPC must not overlap. Special address arrangements, including documented BYOIP behavior, need their own rules. See subnet CIDR blocks.

Capacity planning counts addresses used by interfaces and managed services, not only visible EC2 instances. A diagram with ten server icons can consume more than ten addresses. Leave deliberate room for replacement resources, scaling and additional service interfaces. Otherwise, a deployment that temporarily launches new resources before removing old ones can fail even though the steady-state diagram looks small.

Also consider networks that may connect later. If a campus network and a VPC use overlapping ranges, the same destination can become ambiguous across a connection. Address planning therefore includes existing corporate ranges and future connectivity requirements. Choosing a familiar private range at random can create work later when teams need to connect systems.

Use explicit address-family labels. An IPv4 default route does not describe an IPv6 path, and an IPv4 security rule does not automatically authorize IPv6 traffic. A dual-stack design has both families and needs corresponding decisions. The exercises here use IPv4 to keep the arithmetic approachable, while later sections explain the different role of IPv6 egress.

3. Separate application roles from availability placement

A subnet is an address range within the VPC and resides entirely in one Availability Zone. You can create several subnets in one zone or distribute subnets across zones. Subnet placement and application role are different dimensions: “application subnet” describes intended use, while “zone A” describes placement. Read the subnet documentation.

Imagine the workshop has a web entry, an application server and a database, all in three subnets within one zone. That arrangement can demonstrate separation of traffic policy, but the three subnet boxes do not provide protection against losing that zone. To discuss availability, examine where running capacity and data recovery capabilities actually exist, not merely how many subnet names appear on the drawing.

A teaching project can begin with one instance per role so the request path remains visible. Describe it honestly as a learning topology. A production design may need multiple application targets, an appropriate database availability arrangement and carefully planned dependencies. Adding a second empty subnet does not duplicate the application or make a single database highly available.

The word private also needs a precise meaning. A private subnet has no direct route to an internet gateway. It can still communicate through other configured paths, including within the VPC or to connected private networks. A public subnet has a direct internet-gateway route. Naming a subnet private or turning off automatic public-address assignment does not, by itself, establish the full intended isolation.

Inspect the actual association between a subnet and its route table. A subnet without an explicit custom association uses the VPC's main route table. Therefore a change to the main table can affect several subnets that an operator did not consider. Before editing a shared network component, list which resources use it and compare that scope with the proposed change.

A default VPC supplies convenient initial components, but it may have been changed or removed. A custom VPC lets you define the intended arrangement explicitly. Neither label proves the network is suitable for your application. Read the current configuration and understand its relationships instead of relying on what a newly created account would normally contain.

4. Read a route as a destination and a next target

A route contains a destination range and a target. A subnet route table directs traffic according to the destination address. Common targets include local VPC routing, an internet gateway, a NAT gateway and private network connections. These entries describe forwarding decisions; they are not a list of application permissions. See route tables.

In our simple model, the application subnet has a local route for the VPC range and an optional default route for approved external traffic. A database address inside the VPC matches the local range. It does not need to leave through the public internet merely because its subnet differs from the application's subnet. Communication still depends on the remaining access controls and service configuration.

When several destination ranges match, the most specific matching prefix normally wins. For example, a route to a particular office range is more specific than a default route covering all IPv4 destinations. Equal-prefix cases and different route sources have additional priority rules. Do not use display order as the decision rule. See route priority.

The IPv4 default destination 0.0.0.0/0 means every IPv4 address matches that range. More specific matches take precedence. Calling it “the internet route” is a convenient shorthand only when its target and the rest of the design make that meaning correct. The same destination can point to different targets in different tables.

Trace the return path as well as the forward path. A client sends a request toward the server; the server sends a response toward the client's address. For connected networks, both sides need an appropriate route arrangement. A one-direction drawing can conceal an absent return route or an unexpected translation that changes the addresses seen by the receiving side.

Finally verify the selected target's state. A route entry referencing an unavailable or deleted resource is not a working path. When diagnosing a failure, record the actual destination address, associated table, selected route and target. This turns a vague statement such as “the routing looks fine” into a sequence another person can inspect.

5. Connect public access without exposing every component

An internet gateway supports internet connectivity for a VPC when attached and used by suitable routing. Direct IPv4 internet communication for an EC2 instance also requires public IPv4 addressing; the gateway performs the mapping between that public address and the instance's private address. IPv6 has its own addressing and routing requirements. See internet gateway behavior.

For a simple public web-server exercise, imagine a student connecting to the server's intended public address on HTTPS. The path needs the relevant route and address arrangement, traffic permission and a listening HTTPS service. A certificate and correct hostname handling are additional application-facing requirements. Attaching a gateway completes only one part of this chain.

A larger design can put a public load balancer at the entry while keeping application targets on private addresses. The student-facing connection terminates at the entry, which makes a separate connection toward the application. The application does not need its own public address merely because students use it through that entry. Label the two connections clearly to avoid opening backend access unnecessarily.

The database's audience is the application, not the student's browser. Its network policy should reflect the actual application source and database port. A browser-based page that can save a registration does not imply that the browser directly connected to MySQL. The application interpreted the request and performed the database operation using its own connection and identity.

Keep management separate from student traffic. A publicly reachable website and an administrator's access path have different source requirements and authentication. Making the web port available does not require making every management port available. Write these as separate rows in the connection plan so the reason for each permission is visible.

6. Use security groups to describe allowed resource traffic

A security group controls allowed inbound and outbound traffic for associated resources. Rules specify properties such as protocol, port and source or destination. Security groups are stateful: responses to permitted traffic are allowed without a separate opposite-direction rule for that response. This does not make every other network control stateful. See security groups.

Security-group rules allow traffic; they do not contain explicit deny rules. When several groups apply to a resource, their permissions are combined. Attaching a restrictive-looking second group does not cancel a broader permission from the first. A supported group reference identifies relevant traffic from associated interfaces; it does not copy the referenced group's rules. See security-group rule behavior.

For the workshop, write the intended connections in plain language before translating them into rules. The public entry accepts the selected web protocol from its intended audience. The application accepts its service connection from the entry. The database accepts its database connection from the application. In a straightforward same-VPC design, appropriate group references can express these relationships without hard-coding every changing instance address.

Do not treat group membership as a person's login. A network rule can permit a database connection, but database authentication and application authorization still determine what the connecting program may do. Similarly, an allowed HTTPS connection does not authorize a visitor to edit every workshop. Network controls and application permissions protect different boundaries.

Evaluate the source actually seen by the destination. A reverse proxy opens a new connection, while other forwarding or translation arrangements can behave differently. A source restriction based on the wrong assumption may block legitimate traffic or permit a broader audience than intended. Draw the connection endpoints and confirm the architecture's source behavior before choosing the rule.

A useful review includes a negative expectation. Our database should accept the intended application connection and reject an unrelated web-only source. Merely proving one positive request works does not demonstrate that the boundary is as narrow as intended. Test negative cases through approved methods and keep their scope clear.

7. Follow both directions through a network ACL

A network ACL applies at a subnet boundary. It has separate inbound and outbound rules with allow or deny actions. Rules are evaluated by ascending rule number, and the first matching rule decides the result. ACLs are stateless, so a permitted request does not automatically permit its reply. They are evaluated when traffic enters or leaves the subnet, rather than for traffic routed within that same subnet. See network ACL behavior.

Consider a TCP client using source port 51000 to contact a server's HTTPS listener on port 443. The request travels from the client address and port 51000 to the server address and port 443. The reply reverses those endpoints: its destination port is 51000. An outbound ACL rule permitting only destination port 443 does not describe that reply.

The temporary client port is often called an ephemeral port. Actual ranges vary with the operating system and relevant network components. Plan rules for the real traffic pattern instead of copying one port range without context. AWS provides an ACL example including response ports. The offline exercise below uses one exact port to make the direction visible.

Rule order can change the outcome. A broad allow rule with a lower number can match before a later narrow deny. Reading only the deny line would then give the wrong expectation. Work from the lowest number and stop at the first match. This differs from route selection, where the most specific matching destination normally wins; do not transfer one component's decision rule to the other.

Default and custom ACLs can begin with different rule sets. Inspect the selected association and actual rules rather than assuming a subnet uses the ACL you recently edited. A rule saved in an unassociated ACL does not affect the subnet. Also remember that an ACL change can affect every relevant resource in its associated subnets, so its scope may be wider than one application server.

Some AWS-provided traffic has documented filtering exceptions, including the VPC DNS resolver and instance metadata paths. Do not claim that an ordinary ACL can control every possible packet. Use the service-specific controls for those requirements. For beginner troubleshooting, the main habit is to identify the actual traffic and applicable control before assuming a newly added deny rule has the intended effect.

8. Choose outbound and administration paths for their purpose

An application server may need to retrieve a package from an external repository without accepting unsolicited internet connections. A public NAT gateway can support suitable outbound connections from private addresses and their replies. The traditional zonal arrangement uses a public subnet, an Elastic IP and a path through an internet gateway. Private NAT serves different private-network connectivity needs. See NAT gateway types.

Current AWS options also include Regional NAT gateways. In automatic mode they expand across Availability Zones according to workload presence and do not require a public subnet to host the gateway. Expansion behavior, supported use cases and costs still need review; Regional NAT does not support private NAT connectivity. Avoid treating the older per-zone topology as the only possible design. See Regional NAT gateways.

NAT is not required just because a subnet is private. Our application can contact its database through the intended private VPC path without using public NAT. If all needed dependencies have suitable private access, general internet egress may not be part of the design. List required destinations first, then select the connectivity that meets those requirements.

A bastion host solves an administration problem. An administrator reaches the bastion through an approved path and uses it to reach a private target. It is not automatically a NAT gateway for every application download. Systems Manager Session Manager provides another management approach without opening inbound management ports, subject to its agent, identity and service-connectivity requirements. See Session Manager.

For native IPv6 outbound-only internet communication, an egress-only internet gateway can allow initiated traffic and its replies while preventing internet-initiated connections through that path. It is distinct from IPv4 NAT. DNS64 and NAT64 address a different case involving IPv6 clients reaching IPv4 destinations. Choose based on address families and requirements, not the assumption that every egress path must perform the same translation. See IPv6 egress-only gateways.

For a lab, calculate the resources that the selected design would leave running. NAT gateways, public IPv4 addresses, endpoints and logs can have their own charges. Removing one EC2 instance does not necessarily remove these resources. Keep an inventory and check current pricing for the actual Region and feature before a real exercise; the offline models here incur none of those charges.

9. Resolve the intended name and select the intended service path

The application usually uses a database hostname rather than a memorized address. DNS resolution selects address information for that name; it does not establish the later TCP connection or authenticate to the database. Record both the configured name and the address observed from the application environment when diagnosing a connection problem. A laptop and an instance can have different DNS views.

AWS provides DNS resolution for VPCs, and VPC DNS attributes affect supported hostname behavior. Private hosted zones and custom resolver arrangements add further configuration. Check the relevant environment and association instead of assuming that a name resolving on a public website will resolve identically inside a private network. See VPC DNS attributes.

For supported AWS services, interface endpoints use AWS PrivateLink and network interfaces in selected subnets. Private DNS can allow the normal service hostname to resolve to the endpoint's private addresses. Connectivity, endpoint security and service authorization all remain relevant. See access through AWS PrivateLink.

Gateway endpoints for S3 and DynamoDB provide another pattern. They use service-prefix-list routes in selected route tables and do not require a NAT device or internet gateway for that supported path. Gateway endpoints do not use PrivateLink. Their route associations and access policies matter. See gateway endpoints.

Picture the workshop exporting a report to S3. A suitable endpoint can provide the network path, while the application's AWS identity and applicable service policies determine whether the write is authorized. If the service returns an access-denied response, adding an internet route is not an automatic remedy. The response may already demonstrate that a service was reached, leaving authorization as the relevant investigation.

Always identify the endpoint actually used. Creating an endpoint does not prove that every request takes that path. DNS answers, route associations, selected Region and application configuration can affect the result. Compare these observations with the intended design before claiming that a dependency now uses private connectivity.

10. Trace one registration through three separate connections

Start with the student's browser. It resolves the workshop name and opens the intended HTTPS connection to the web entry. The entry needs a suitable listener and certificate. The browser submits the registration request through that connection. At this point the request has reached the public-facing component; the registration is not yet necessarily stored.

The web entry then makes a separate application connection. In this overview, we use a fictional HTTP application listener on port 8080. That port is a chosen configuration, not a universal application standard. The entry's target configuration, network path, permission and the application's bind address must agree. A process listening only on its own loopback address cannot normally receive a connection from another machine's private interface.

The application validates the request and opens its database connection. In the MySQL example the selected listener uses port 3306. The application supplies database credentials or another supported authentication mechanism. Its network identity and its database identity are separate concepts. A successful TCP connection can still be followed by authentication failure, permission denial or an invalid query.

After the database commits the intended operation, the application builds a response and the entry returns it to the browser. Verification should compare the response with a subsequent read of the saved registration. This follows the user outcome across the three connections. A successful ping, a reachable web page and a successful database login are narrower observations.

Create a connection worksheet with one row per connection: source role, destination role, protocol, listener port, route expectation, allowed source and useful success check. Add the management and dependency connections as separate rows. This worksheet is a more precise basis for rules and troubleshooting than a diagram with unlabeled arrows between every box.

11. Work through address, route and reply-port exercises

The following blocks use Python 3 with a Bash-compatible shell or zsh. They operate on supplied values in memory, without network traffic, AWS credentials or file changes. Predict each output before executing it. These are focused reasoning models, not a complete AWS network simulator or proof that a real network is reachable.

Lab 1: Validate the three subnet ranges

The first block checks that each proposed subnet fits within the parent and that no pair overlaps. It prints total addresses and the ordinary IPv4 assignment capacity after the five reserved addresses. The final deliberately overlapping proposal demonstrates why comparing only the names of two subnets is insufficient.

python3 - <<'PY'
from ipaddress import ip_network
from itertools import combinations
parent = ip_network("10.44.0.0/16")
subnets = [ip_network(x) for x in (
    "10.44.10.0/24", "10.44.20.0/24", "10.44.30.0/24"
)]
assert all(s.subnet_of(parent) for s in subnets)
assert all(not a.overlaps(b) for a, b in combinations(subnets, 2))
for subnet in subnets:
    print(subnet, "total=" + str(subnet.num_addresses),
          "ordinary_assignable=" + str(subnet.num_addresses - 5))
bad_proposal = ip_network("10.44.20.128/25")
assert bad_proposal.overlaps(subnets[1])
print("overlapping proposal rejected:", bad_proposal)
PY

Expect three rows with 256 total and 251 ordinarily assignable addresses, then the rejected overlapping range. The arithmetic does not tell you how many addresses are currently free, because existing interfaces and other allocations consume capacity. Explain that difference before using the result to estimate the resources a real subnet can still accept.

Lab 2: Choose the most specific supplied route

This model includes the local VPC range, a fictional office connection and a default egress target. The labels are abstract targets, not existing AWS resources. All supplied prefixes differ, so the exercise demonstrates longest-prefix selection without modeling AWS's additional equal-prefix and route-source priorities.

python3 - <<'PY'
from ipaddress import ip_address, ip_network
routes = [
    (ip_network("0.0.0.0/0"), "egress-target"),
    (ip_network("10.44.0.0/16"), "local-vpc"),
    (ip_network("172.20.40.0/24"), "office-connection"),
]
def choose(text):
    address = ip_address(text)
    matches = [(network, target) for network, target in routes
               if address in network]
    return max(matches, key=lambda row: row[0].prefixlen)
expected = {
    "10.44.30.25": "local-vpc",
    "172.20.40.9": "office-connection",
    "203.0.113.8": "egress-target",
}
for address, target in expected.items():
    network, selected = choose(address)
    assert selected == target
    print(address, "matches", network, "selects", selected)
PY

The database address selects local VPC routing, the office address selects its specific connection and the documentation-only external address selects the default target. The model sends no packets to any of them. Notice that the default route appears first in the list but does not win the first two decisions. Reordering the list would not change those results.

Now reason about deleting the default route on paper. The local and office examples still have matching routes, while the external example no longer does. That does not imply the two retained paths are fully operational; their targets, permissions and services still need verification. A route-selection result answers one limited question.

Lab 3: Find the missing reply permission

The final model considers a server subnet and one HTTPS client using temporary port 51000. Its simplified ACL rules contain only rule number, destination-port range and action; protocol and address matches are assumed true for this exercise. The initial outbound rule incorrectly allows only destination port 443, so the reply to the client's temporary port is denied.

python3 - <<'PY'
def decision(rules, destination_port):
    for number, low, high, action in sorted(rules):
        if low <= destination_port <= high:
            return action, number
    return "DENY", "implicit"
inbound = [(100, 443, 443, "ALLOW")]
outbound = [(100, 443, 443, "ALLOW")]
request = decision(inbound, 443)
reply_before = decision(outbound, 51000)
print("request:", request, "reply before:", reply_before)
assert request[0] == "ALLOW" and reply_before[0] == "DENY"
outbound.append((110, 51000, 51000, "ALLOW"))
reply_after = decision(outbound, 51000)
assert reply_after[0] == "ALLOW"
print("reply after:", reply_after)
ordered = [(100, 1, 65535, "ALLOW"), (200, 443, 443, "DENY")]
assert decision(ordered, 443) == ("ALLOW", 100)
print("first matching rule wins:", decision(ordered, 443))
PY

Expect the request to pass, the first reply decision to fail and the revised reply decision to pass. The last case shows a broad earlier allow winning before a later deny. Do not copy the exact one-port correction into a real ACL: a real client can choose a different ephemeral port, and the actual protocol, addresses and required ranges must be considered.

To extend the exercise, explain which checks the model omits: subnet association, both endpoint addresses, protocol, other subnet boundaries, security groups, target availability and a listening service. Listing the omissions helps you use a model responsibly. A small program can clarify one decision without reproducing every behavior of the system it teaches.

12. Troubleshoot the specific connection that failed

Write the observed operation first. “Registration fails from the web entry to the application on the configured port” gives you a source and destination to investigate. “AWS networking is broken” does not. Record the resolved destination, time, failure message and expected listener. Keep comparisons at the same observation point; a successful laptop test may use a different route and source address.

A timeout can result from several causes, including routing, filtering or an unavailable destination. A connection refusal often indicates an actively responding component rejected the connection, but it is not a universal proof of the exact rejecting layer. An HTTP response moves the investigation further into the service path. Use the observation to narrow the next check rather than assigning every error one memorized cause.

VPC Flow Logs provide information about IP traffic to and from interfaces, subject to documented scope and delivery limits. They can support investigation of traffic direction and acceptance or rejection. They are not full HTTP request bodies or database transaction logs. Correlate them with appropriate application evidence. See VPC Flow Logs.

Reachability Analyzer evaluates supported network configuration paths and can identify blocking components. It is a configuration analysis tool, so a successful result does not prove that the guest application is listening, authentication succeeds or a registration commits. Use it alongside workload checks. See Reachability Analyzer.

Make one evidence-based correction at a time and repeat the relevant positive and negative tests. If a broad temporary rule is used in an approved diagnostic procedure, record its scope and restore the intended policy afterwards. A useful fix explains the original failure and preserves the desired boundaries; it should not depend on leaving every component broadly reachable.

13. Interview questions with connected explanations

1. Why separate a public entry from private application resources?

The audiences differ. Students need the website's public interface, while application and database connections can stay on the intended private paths. A public entry can receive a request and make a separate backend connection. I would define the required sources and listeners for each connection, then verify the user operation and the intended restrictions. Private placement helps the design, but it does not replace permissions or application authentication.

2. Does placing an instance in a public subnet make it reachable?

No. Public describes the direct internet-gateway routing arrangement. Direct access also needs suitable addressing, permitted traffic and a responding service, with any relevant host firewall and protocol configuration. I would inspect those components separately. A subnet name and a public-address field are not sufficient evidence that the expected website will load.

3. How do route-table and ACL decisions differ?

Routing selects a path toward a destination, normally using the most specific matching prefix. An ACL evaluates numbered permission rules in order and applies the first match. A route can exist while the ACL denies traffic. Conversely, an ACL allow does not create a missing route. I would explain both decisions for the actual packet before checking the listening application.

4. Why can a request pass an ACL but its reply fail?

The ACL does not automatically remember and permit the opposite direction. The reply has reversed endpoints, including a destination port corresponding to the client's temporary source port. An outbound rule allowing only the server's listening port can therefore miss the reply. I would inspect the actual traffic tuple and required ranges rather than copying the inbound rule unchanged.

5. Must every private subnet use NAT?

No. NAT is selected for a connectivity requirement, such as appropriate outbound access to external IPv4 services. Internal application-to-database traffic can use its private path. Supported AWS service endpoints may provide another path. I would inventory dependencies and address families before choosing egress resources, then consider their availability, policy and cost.

6. What does a security-group reference mean?

In a supported arrangement, it permits the specified traffic associated with interfaces using the referenced group. It is useful for describing a relationship such as application-to-database access. It does not import the other group's rule set or create a network route. I would also verify the source behavior if a proxy, translation or middlebox changes the connection path.

7. How would you investigate a failed database connection?

I would start from the application environment and record the configured hostname, resolved address, port and actual error. Then I would inspect the relevant route, controls and listener, followed by database authentication and authorization. A connection timeout and an access-denied database response lead to different next steps. Finally I would verify the intended query and saved result.

8. Do three subnets make a three-tier application highly available?

No. Subnets describe address ranges and placement; availability depends on running capacity, data behavior and dependencies across failure boundaries. Three roles in one zone remain exposed to losing that zone. I would distinguish the teaching topology from a resilient deployment and explain which resources and recovery mechanisms actually sustain the service.

14. Quiz: choose the next useful conclusion

Quiz 1: A route to the database exists, but its process is stopped. Will adding another route help?

The supplied evidence points to the missing listener. Restore or investigate the database service through its appropriate procedure, then verify connectivity and the application operation. Another route does not start the process. Also confirm that the original route and other requirements really match the intended destination rather than relying on a similarly named resource.

Quiz 2: A subnet is named private but its table has a direct internet-gateway route. Which description is trustworthy?

The actual configuration determines the routing behavior. The name is a label and can be wrong. Inspect the association, routes and address families, then correct the design or the documentation according to the requirement. Do not change a shared route table before checking which other subnets depend on it.

Quiz 3: An extra security group has no inbound rules. Does it cancel another group's broad allow?

No. Applicable security-group permissions combine. An empty group does not add a deny that overrides the other group. Review the complete set associated with the resource and modify the relevant permission if the intended boundary is narrower. Verify both the permitted application source and the source that should remain excluded.

Quiz 4: A private endpoint exists, but the service returns access denied. Is NAT automatically missing?

No. A service response can indicate that a responding endpoint was reached. Investigate the identity and applicable access policies while confirming the actual endpoint used. Network access and authorization are separate requirements. Adding an unrelated egress path does not grant the application permission to perform the denied operation.

Quiz 5: An IPv4 connection works. Has IPv6 access been tested too?

No. The address families have distinct routes and applicable rules. Test the intended IPv6 name result, selected address, path and service behavior separately if the design supports IPv6. A dual-stack hostname can lead clients to different families, so incomplete configuration can produce different experiences for different users.

15. Revision cards for reading a network diagram

Address card — range before individual resource

Check parent containment, non-overlap and assignment capacity. Then account for the interfaces and service resources that will actually consume addresses, including temporary replacement capacity.

Placement card — role and zone are different labels

A role explains the resource's job. A zone explains its placement. Several role subnets in one zone do not, by themselves, provide a multi-zone service.

Routing card — destination selects the path

Use the actual associated table and destination address. Apply the relevant prefix and priority rules, then inspect the selected target and return path.

Permission card — follow the connection endpoints

Identify who initiates the connection and the source actually seen by its receiver. Evaluate security groups and applicable subnet boundaries without assuming one control overrides the others.

Egress card — begin with the dependency

State which external or private service is required and its address family. Select NAT, an endpoint or another suitable path because it meets that requirement.

Evidence card — prove the useful operation

Configuration checks and traffic observations support diagnosis. Confirm the application result separately, such as a registration readback, before declaring the whole request path healthy.

16. Tasks for a complete network explanation

  1. Draw the three conversations. Use separate arrows for browser-to-entry, entry-to-application and application-to-database. Label each source, destination and configured port. Add one useful response check for every arrow and explain why a successful first arrow does not prove the last.
  2. Review a fictional address plan. Propose two non-overlapping application subnets within the supplied VPC range, one per example zone. Calculate ordinary IPv4 assignment capacity and reserve room for replacement resources. Describe which connected-network ranges would need review before using the plan.
  3. Explain a reply failure. Draw the HTTPS request and response with both endpoint addresses and ports. Show an ACL that permits the request but misses the reply. Then describe the appropriate real-world checks before selecting an ephemeral range for a correction.
  4. Compare two dependency plans. In one, the application needs only the private database and supported AWS service access. In the other, it must contact an external package repository. Explain which connectivity requirements differ and which identity or application permissions remain necessary in both.
  5. Teach the failure to a classmate. Choose a DNS failure, missing route, denied connection or stopped listener. Give observations that support that diagnosis and one observation that would contradict it. This teaches troubleshooting as reasoning from evidence instead of memorizing one command for every symptom.

Official references

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Maple Leaf Books is a bookselling business in Toronto. Emily Tremblay looks after its IT and cloud work. They count money in CAD and run their AWS resources in the ca-central-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 12

Easy How many addresses in a /16?

Picking a VPC size needs this count.

Maple Leaf Books plans the VPC 10.131.0.0/16. How many IP addresses does it hold in total?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Create a VPC

A VPC is a logically isolated virtual network for supported resources. Some AWS services are accessed through service endpoints rather than living inside your VPC.

Create a VPC with the CIDR block 10.5.0.0/16.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Create an internet gateway

An internet gateway supports direct internet connectivity through suitable routing and addressing. Other approved architectures can use connected networks for egress; attaching this gateway alone does not make a service reachable.

Create a new internet gateway.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Create a subnet in one AZ

Subnets split the VPC range and each one lives in exactly one AZ.

In vpc-0e32412000deadbee, create subnet 10.5.1.0/24 in ca-central-1a.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Add the internet route

A public subnet has a direct internet-gateway route. The common IPv4 default route is 0.0.0.0/0, but narrower destinations and IPv6 routes are also possible.

In route table rtb-002d32412000bb22, send all internet traffic (0.0.0.0/0) to igw-02d32412000aa11.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Find the VPC router address

AWS reserves base+1 for the router.

Which address does AWS reserve for the VPC router in subnet 10.131.4.0/24?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Usable IPs in an AWS /24 subnet

For this ordinary AWS IPv4 subnet exercise, five addresses are reserved; special arrangements have their own documented behavior.

How many addresses can Maple Leaf Books use for servers in subnet 10.131.1.0/24 on AWS?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Link a subnet to a route table

A subnet without an explicit custom association uses the VPC main route table. Review all dependent subnets before changing a shared table.

Associate subnet subnet-002d32412000bb1 with route table rtb-002d32412000bb22.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Attach the internet gateway

This internet gateway must be attached to the intended VPC, with suitable routes and resource addressing, to support the planned internet path.

Attach igw-02d32412000aa11 to vpc-0e32412000deadbee.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Pick the smallest prefix

Right-sizing saves address space.

A subnet must hold 100 servers on AWS. What is the largest prefix number (smallest subnet) that fits? Answer like /25.

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Split a /24 into two

Public and private subnets often split one block.

Split 10.131.8.0/24 into two equal subnets. Write both CIDRs separated by a comma.

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Create a NAT gateway

This browser exercise uses a public zonal NAT gateway and a public subnet. NAT is selected for required egress; current Regional NAT and private service endpoint designs differ.

Create a NAT gateway in public subnet subnet-002d32412000bb1 using Elastic IP allocation eipalloc-02d32412000dd44.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.