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

AWS Cloud

Chapter 1: Networking Fundamentals

Hello, friends! Before launching any server on the cloud, let's understand how computers find each other and how they talk. Security groups, VPC, subnets, Elastic IP, load balancers – all these cloud concepts stand on basic networking. In my class many students want to jump straight to EC2, but I always say: networking first, then cloud. In this chapter we take one example along: a dairy brand like Amul (sample data, for practice) – its order website, its office Wi-Fi and, later, a VPC on AWS. If this chapter is clear, AWS networking will feel very simple.

In this chapter

  • Why networking matters on AWS
  • IP addresses, ports and sockets
  • IPv4, CIDR and subnetting
  • IPv6 format and shortening
  • Static vs dynamic IP
  • Public vs private IP and NAT
  • How it all maps to a VPC

Concepts in this chapter

  1. 1.1Why networking matters in the cloud
  2. 1.2IP address — what and why
  3. 1.3Ports
  4. 1.4IPv4 in detail
  5. 1.5IPv6
  6. 1.6Static vs dynamic IP
  7. 1.7Public vs private IP
  8. 1.8NAT (Network Address Translation)
  9. 1.9How these concepts map to AWS

Review and practice

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

Follow the three application connections

Follow the three application connectionsBrowserRequests the order pagePublic entry pointReceives HTTPS trafficPrivate applicationProcesses the orderDatabase and responseStores the result, replies
Read all steps
  1. Browser

    The browser resolves the site name when needed and connects to the intended public service. This proves only the first connection; loading a page does not prove that a later database operation will work.

  2. Public entry point

    The entry point can terminate the visitor’s connection and open a separate connection to an application target. Its listener, target port and target health are separate checks.

  3. Private application

    The application validates the submitted order and requests a database change. It acts as a server for the incoming request and as a client for its database request.

  4. Database and response

    A successful database result travels back through the application response. Follow failures along these separate connections instead of assuming that one working page proves every dependency is healthy.

Follow one order from the laptop to AWS

Start with a small dairy’s order desk. A shop assistant opens the order page, enters twelve packets of milk, and presses Save. The page answers in a second. On the next shift, another assistant opens the same page and sees the new order. Something took the first person’s request to the program that records orders and brought the result back. Computer networking is the set of connections and rules that make that exchange possible. Once you can draw this exchange, building a VPC or opening a security group rule feels like solving a concrete problem.

We will use an invented site called orders.dairy.example. It is a paper example. The IPv4 addresses beginning 192.0.2., 198.51.100. and 203.0.113. and the IPv6 addresses beginning 2001:db8: are used for documentation. When a lab asks you to try a real connection, use a resource you operate and the actual address it shows. The local practice exercise farther down needs only your own computer.

  1. The shop assistant’s browser reads the site name. The computer can use DNS, the Domain Name System, to find a destination address for that name. It might already have a recent usable answer.
  2. The laptop checks its network configuration and selects a route. For a destination outside the local network, this usually sends the first packet to a router such as the office gateway.
  3. Routers move the packets onward. For this example, the final network has a public front door for the ordering service. The laptop and the public front door must be able to exchange traffic on the chosen protocol and port.
  4. The browser sets up the connection it needs for HTTPS and checks the identity of the site. It can then ask for the order page. The same browser may make several later requests for images, scripts and saved orders.
  5. The public web service accepts the request. It may serve its own page or forward the request to a separate private application. The application can make its own request to a database, then return a result.
  6. The browser receives that result and displays it. A success message should mean the application did the work it promised. Reachable networking is one requirement for that promise. The program and its data must also be correct.

Notice the two meanings of “client.” The browser is the client when it asks for the page. The order application is the client when it asks the database for a row. Client and server describe roles in a particular exchange. The same machine can run a server program and a program that calls another service. This helps later when a private EC2 instance receives a request from a load balancer and sends its own request to S3.

Draw three arrows before trying to diagnose the entire site. Write browser to public entry point, entry point to application, and application to database. A working arrow says nothing by itself about the other two. When the order page opens but saving an order fails, ask which part was already proved by opening the page. The goal of this chapter is to inspect each network decision with the same discipline.

Read the destination before choosing a route

Read https://orders.dairy.example/today as three parts. https gives the browser the communication rules and normally implies port 443. orders.dairy.example is the host name. /today asks the web application for a particular path. Draw another URL with /yesterday. The host is the same. The web app will receive a different request after the connection arrives. The routers on the way there do not need to choose anything based on the menu path.

A DNS resolver is the service that supplies an answer for the name. An A record can provide an IPv4 address and an AAAA record can provide an IPv6 address. A name can produce more than one address. Your browser and operating system determine which usable address to try. A resolver can cache a record for its normal time to live, or TTL. When an administrator updates a DNS record, an earlier valid cached answer can persist for a while. Write down whether your test asked a cached resolver or the authoritative source that holds the new record.

Suppose DNS says the site is at 203.0.113.20. The router still needs a rule that says where to send packets for that address. A route table contains rules based on destination ranges. A rule can name another router as the next hop. It can also identify a range the computer reaches directly over a local interface. For a home or office computer, the default route gives a way out when no more specific entry applies. On Linux, ip route shows the IPv4 routes in a familiar classroom format. A line such as default via 192.168.40.1 dev wlan0 means the route uses that next router through the wireless interface. It does not say that every packet goes through the gateway.

Take an office laptop at 192.168.40.18/24. A printer at 192.168.40.30 on the same local network can be reached locally if the network permits it. The laptop recognizes the address as part of its directly connected range. For the remote documentation address 203.0.113.20, the default route is a possible next step. The IP destination remains the site’s address. The laptop sends the packet to its gateway over the local link so that the gateway can carry it farther. The gateway’s own address and the destination for the whole journey are distinct.

Try a route selection exercise. One machine has three routes: 192.168.40.0/24 directly connected, 10.30.0.0/16 to a company router, and 0.0.0.0/0 to its default router, which provides the path toward the internet. The destination 10.30.12.9 matches the last two ranges. Choose the /16 because it matches a longer prefix of the destination address. The default remains the answer for an address with no more specific match. This is the same reasoning you will apply when comparing routes in a VPC subnet.

DNS and routing are two independent checks. If a query gives the expected address but connecting to it times out, the lookup already provided a useful answer. You can now inspect the path and permissions. If an authorized connection to the address works but the hostname fails, look at which address each test actually used, and remember that an HTTPS certificate is checked against the requested name. Directly typing an address into a browser changes what the browser asks the certificate to prove.

Identify the network interface and the addresses it uses

Your laptop can have Wi-Fi, a wired connection, and a VPN at the same time. An interface is a connection the operating system can use to exchange traffic. One interface can have several addresses. If you list them all, you may see an address for a disconnected adapter, a local IPv6 address, and a separately assigned IPv4 address on Wi-Fi. Find the interface used for this particular destination before copying an address into your notes. The machine’s job, the interface and the network address are three distinct ideas.

An IP packet has a source and a destination. When the browser sends a request, the address chosen on the laptop identifies one side and the remote service identifies the other. A reply needs the network to reach the appropriate return destination. Routing can change which link carries the reply. In addition, a device doing Network Address Translation can change the visible source or destination values while it forwards. Keep track of the addresses at the point you are observing rather than assuming the same source is visible everywhere.

Here is a practical reason to check interfaces first. Suppose the order desk opens its private printer over office Wi-Fi, then connects to a company VPN. The laptop may now have an additional private address and route to internal systems. Copying the Wi-Fi address into an AWS access rule would be wrong for a request that actually travels to the public endpoint through the company’s internet connection. First inspect the correct side of the connection. An adjustable rule must match the address the destination receives for that path.

When a Linux program listens on 127.0.0.1, its IPv4 address refers to that same system through loopback. A call from the EC2 terminal to this address stays on EC2. The same command on your laptop stays on your laptop. If your own service responds on loopback, you have useful evidence about its process and path. You still have a different test to perform if a separate lab computer must reach it. Binding a service to all local IPv4 interfaces, often written as 0.0.0.0, changes where the program waits for traffic. Security groups, operating-system firewalls and routes are independent of that setting.

Use a small identification table in the notebook for the order lab. Write down your local IPv4, its prefix, the first gateway on the path, the hostname you entered and the destination address you expected. If you run an SSH command, write down the name of the remote computer as soon as you connect. This prevents a common mistake where a student checks the laptop’s network settings while thinking their terminal is already logged into AWS. After login, commands such as hostname and ip addr describe the remote machine.

Use the transport protocol and port to find the service

One server can run the order website and an SSH service. The address gets the traffic to the server. A transport port is a numbered field that identifies the network endpoint used by a program. TCP and UDP have their own port spaces. A rule for UDP port 443, for example, is different from a rule for TCP port 443. In the simple website experiment here the website listens on TCP 443. SSH commonly listens on TCP 22. You can allow one kind of exchange without allowing the other.

For a normal TCP connection, the browser opens a connection from a local address and a temporary source port to the service’s address and port. Suppose its example source is 192.168.40.18:51030 and its destination is 203.0.113.20:443. After the initial TCP exchange, each side can send data. Other clients can also reach port 443. The connection state includes both addresses and both ports, which lets the operating system distinguish these different exchanges. The reply has source port 443 and a destination port matching the client’s side of that connection.

Write three labels on a drawing of the checkout. The network rule says which traffic can reach the machine. The listener is the running program waiting for the connection on an address and port. The application path decides what the receiver does when it sees the request. Opening TCP 443 in an AWS rule does not start a listening program. Starting the program does not approve network access. A successful connection also does not make every URL valid. This is why a network timeout, an immediate refusal and an HTTP 404 help you look in different places.

TCP provides an ordered stream and reliability mechanisms. UDP carries individual datagrams and does not provide TCP’s built-in connection or delivery behavior. Application protocols can add their own handling on top of UDP. DNS is a useful reason to avoid simple memorization: common DNS requests can use UDP port 53, and DNS also uses TCP in supported cases. A security configuration should describe the protocol the application actually uses on that path. In a lab bug report write TCP 8080, UDP 53, or HTTPS to the named host instead of writing only a port number.

Connection in the dairy sketchCommon destinationOne way to verify it
Browser to the order siteTCP 443 for this HTTPS exerciseOpen the expected hostname and inspect the response and certificate.
Administrator to a lab Linux hostTCP 22 for ordinary SSHConfirm it replies using the authorized username and key from your notebook.
Application to a training MySQL serviceTCP 3306 if configured that wayTest with the intended application identity and private path.
Local browser to a disposable Python serviceTCP 8000 in the lab belowAsk for the known page on loopback and inspect the HTTP status.

Suppose http://localhost:8000/today works and https://localhost:8000/today reports a protocol error. When the lab server provides plain HTTP, the branch for TLS will fail even at the correct address and port. Use the application protocol you actually configured. A port number does not automatically make a service encrypted. Check the scheme and the active server configuration as separate choices.

Work out an IPv4 range without memorizing every boundary

An IPv4 address has 32 bits, displayed as four groups of eight. Each eight-bit group can represent values 0 through 255. The written address 10.30.19.40 belongs to some address range, but you need the prefix length to know which boundary a network uses. CIDR, short for Classless Inter-Domain Routing, displays that prefix length after a slash. A /24 means the first 24 bits define the range. The last eight bits can vary inside the range, giving 256 total addresses. A /26 leaves six bits to vary and gives 64 total addresses.

Use the dairy network 10.30.0.0/16 for paper planning. It has 16 varying bits and 65,536 addresses in its block. Dividing it into two /20 blocks changes which third-octet values are grouped together. A /20 leaves 12 varying bits. Four of those are in the third octet, so 16 different third-octet values are in one block. The other eight are in the last octet. Block A is 10.30.0.0/20, from 10.30.0.0 to 10.30.15.255. Block B begins at 10.30.16.0/20 and ends at 10.30.31.255. The two ranges touch without overlapping.

Try finding the block for a proposed address of 10.30.19.40/20. The third octet, 19, falls in the 16–31 range. The block starts at 10.30.16.0. The value typed with the address belongs to that block, but it is not its first address. Before creating an AWS subnet, write the aligned start and check it fits inside the VPC. If a second team proposes 10.30.24.0/20 for a new subnet, you can now explain why it does not provide a separate aligned range. Its addresses are already part of the 10.30.16.0/20 block.

Now design a smaller practice subnet. Put 10.30.40.0/27 on paper. Five bits can vary and there are 32 addresses, from 10.30.40.0 to 10.30.40.31. For an ordinary IPv4 subnet in the AWS VPC lab, the first four and the last address are reserved. This gives 27 assignable addresses in the example, from .4 through .30. Count the whole block first and then the addresses you are allowed to assign. An engineer using a different environment may need a different usable-count rule. For example, special point-to-point prefixes are a separate design case.

Write the result in a three-row table with range, total, and assignable in this AWS subnet. If an instance cannot launch because there are no free addresses, count the resources and interfaces that already consume the range. A load balancer, application interfaces and extra private addresses can all affect capacity. A plan that includes exactly enough addresses for the instances running today leaves little space to add targets during a replacement or traffic surge. Plan future room as part of the first network drawing.

You will still see the old names Class A, Class B and Class C in interview material. They refer to historical classes with fixed default network sizes. In modern design the slash length controls the actual range. The first octet can help you recognize a familiar private range, but it cannot reveal the subnet size by itself. In an interview, read the exact CIDR on the whiteboard before estimating the number of hosts.

Read IPv6 on its own terms

IPv6 uses a 128-bit address, written as groups of hexadecimal digits. Hexadecimal has sixteen digits, from 0 through 9 and a through f. The starting groups play the same practical role as a prefix in IPv4: they identify a range. The larger address space lets networks assign addresses on a very different scale. Many applications support both versions while their users, networks and service dependencies adopt IPv6 at different times. This arrangement is commonly called dual stack.

Take the paper address 2001:0db8:0030:0000:0000:0000:0000:0042. You can remove leading zeros inside each group, giving 2001:db8:30:0:0:0:0:42. The longest run of consecutive zero groups can become a double colon, giving 2001:db8:30::42. To expand it, count how many explicit groups remain and put back the zeros needed to reach eight groups. The double colon appears at most once in one address so there is a unique place to restore the omitted groups. The leading-zero rule does not remove zeros inside or at the end of a nonzero number.

When an interface shows several IPv6 addresses, check the scope of each. A link-local IPv6 address is for communication on the local link and is not routed around the internet. ::1 is IPv6 loopback. A global unicast address can be used across routed networks if the path and permissions permit. Even a global address does not prove that a server is reachable. In AWS an IPv6 route and suitable IPv6 network rules must allow the flow, and the application must listen for it.

Imagine the browser gets an A record for a working IPv4 front door and an AAAA record for an IPv6 front door that a firewall does not yet allow. Different devices can report different symptoms when they select different paths. With a hostname you control, test a real IPv4 and IPv6 request separately using curl -4 and curl -6 on a host that has both connections. If one fails, compare the DNS answer, route, rule and listener for that version. This is more useful than declaring the name either broken or working everywhere.

An IPv4 security group source written 0.0.0.0/0 covers IPv4 addresses. An IPv6 source written ::/0 covers IPv6 addresses. Do not add either broad source to an administrative port just to make a practice connection work. Decide which trusted source should be able to reach the intended service and choose the narrow appropriate rule. The lab below binds to loopback so it does not need any inbound access from other devices.

Decide where an address works and how long it stays

Public and private describe where an address can be used. Static and dynamic describe how it is assigned and whether the assignment is expected to persist. The two distinctions are independent. The office printer may have a reserved private address so staff can always find it. A laptop on the same Wi-Fi may receive a private address dynamically. A disposable EC2 server can have an automatically assigned public IPv4 address. An Elastic IP can provide a stable public address for a standalone EC2 design when that is the right entry point.

IPv4 private ranges from RFC 1918 are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. In the middle range, the second number runs from 16 through 31. 172.20.1.5 belongs to that range. 172.32.1.5 does not. Being outside these three blocks does not prove that an address is publicly usable. Loopback, link-local, shared carrier space and documentation examples have their own special purposes. A cloud engineer should look at how the address was allocated and what its network can route.

Two independent offices can both use 192.168.40.18 internally. Each knows the host on its own local network. If the offices later try to join those networks, their identical ranges make it hard to choose a unique path. The same happens if two VPCs planned for peering use overlapping ranges. Write down the addresses already in use by the organization before deciding on new private space. A harmless-looking default range can become expensive to change after users and servers have come to depend on it.

DHCP can automatically supply an address, prefix information, gateway and DNS resolver settings. The temporary address assignment is called a lease. Suppose the office DHCP server gives the laptop 192.168.40.18 until 7 PM. Closing the laptop briefly does not necessarily cancel its lease. It may use the same address when it reconnects. A static assignment can be set on a device or a DHCP reservation can keep giving the device a particular address. Ask the person who runs the network before setting a manual address on a shared subnet. Choosing an address already in use can disrupt another machine.

For a stable public AWS service, work out what you are trying to keep stable. On a lab EC2 instance an associated Elastic IP can preserve the entry address across a stop and start. The instance can still be unavailable during the stop. In a service that replaces multiple instances, clients can use a stable domain that leads to an AWS load balancer while the targets use changing private addresses. The web service can move independently behind that name. A static address keeps a destination predictable. Availability still depends on healthy paths and working applications.

Follow two devices through one outward address

The order desk’s printer and laptop can reach local devices using private addresses. For an IPv4 order request to an outside site, the laptop sends an off-network packet to the router. When a router performs source Network Address Translation, or NAT, it can rewrite the source so the next network sees an address suited to that side of the path. A type of translation that also tracks ports lets several devices share one outward address and distinguish their replies.

Use two shelf labels on paper. The first says 192.168.40.18:51030 → 198.51.100.10:62001; the second says 192.168.40.19:51030 → 198.51.100.10:62002. Both example devices happen to choose local port 51030 while asking for the same remote order service at port 443. The translated source ports differ. When the reply for port 62001 arrives, the router uses the mapping to identify the laptop. The reply for 62002 is forwarded to the other device. The mapping includes enough connection information to place each packet back on the right local path.

A house’s Wi-Fi router can sit behind carrier-grade NAT, another translation service run by the provider. The public site can therefore see an outward address shared by multiple homes, even when the router’s own WAN screen shows a different address. If you compare two devices as a lab, use the same network and the same IPv4 test. An IPv6 connection or a VPN can make the results different without disproving IPv4 NAT. Record only your observations, and leave router settings unchanged.

Now reverse the question. The private app server can fetch a software update through a translation path that it initiated. That does not give an internet visitor a direct new connection into the private app. An AWS public NAT gateway supports the return traffic for connections initiated from the allowed inside path. The public ordering endpoint should be an intentional service entry point with its own rules, rather than a side effect of how the app downloads packages.

Think about a company that limits administrative access by a public source address. The address it sees can be the office gateway’s outbound address, not the laptop’s 192.168.40.18. If the employee moves to a hotspot or switches VPNs, the allowed path may change. A timeout after the laptop switches networks is a reason to verify its current outbound path and the destination’s policy. Reusing the same internal laptop address on two networks does not prove it appears the same way on the public side.

Put the networking pieces into the dairy’s VPC

A virtual private cloud, or VPC, is the regional network you configure in AWS. A subnet divides that address plan into a smaller range in a single Availability Zone. For this exercise, give the VPC 10.30.0.0/16, with separate subnets for the public entry point and private application. Draw a second set of subnets in another Availability Zone if your design aims to keep serving during a zonal failure. A subnet is the location and addressing decision. The route table and security policies supply their own meanings.

For a direct public IPv4 exercise, the subnet route points internet-bound traffic to an internet gateway. The EC2 network interface has a private IPv4 and the instance has a public IPv4 association. The internet gateway provides the appropriate translation for the public IPv4 path. Inside Linux, the primary address seen by the guest can still be the private one. Confirm both views in your notes. On a real hosted service where visitors connect to a load balancer, front door targets can use private addresses. The target’s operating system should not have to treat every outside visitor as a directly connected host.

Think of three connections. The customer connects to the public entry point on the allowed web port. The load balancer connects to a selected app target on its configured port. The app connects to its database on a private network path with the database’s protocol. Each arrow needs a route, an allowed source and a ready service. Instead of allowing traffic from the whole VPC to every backend port, scope it to the expected tier. In the same VPC design an app security group can accept its app port from the load balancer’s security group. The database security group can accept its database port from the app tier group.

Security groups are stateful: after a permitted connection, related return traffic can pass without writing a second security group rule specifically for that reply. Network ACLs apply to a subnet and evaluate directions separately. If you deliberately make a restrictive ACL in the disposable lab, write out the incoming destination port and the outgoing return destination port before testing. For an inbound HTTPS attempt from TCP 51030 to TCP 443, the reply is addressed back to TCP 51030 on the client side. A rule that allows requests and blocks replies produces a failed connection even though the inbound list appears correct. Use the client port ranges, rule order and actual expected path when interpreting a lab ACL.

Now add a private app that needs outside software updates. In the common public NAT gateway arrangement, the private app subnet’s default IPv4 route points to the NAT gateway. The NAT gateway’s public subnet reaches the internet gateway. The app can keep a private address. If the app already reaches a database in the same VPC, that separate destination can use the local VPC route. The two connections prove different things. When only private EC2 needs to reach an AWS service such as S3, an appropriate VPC endpoint may be a better path for that specific service. It changes the network path; normal service authorization still applies.

Inspect the actual subnet’s route-table association before you infer where packets travel. A route table with a helpful name can belong to another subnet. A healthy load balancer can have unhealthy backends. A security group can allow a connection that still fails because a process is not listening. Working through these separate checks prepares you for the later AWS labs. You can test the same idea without launching anything by using the loopback exercise below.

Observe a working service and a missing page on your own computer

This lab proves the difference between reaching a service and requesting a missing path. Use Python 3 on a Linux or macOS test computer and a shell that supports the commands shown. On Windows, you can perform the equivalent in a Linux shell you already use or launch Python’s HTTP server in an empty folder from PowerShell. Use a new empty directory and a note that contains no private data. The service will listen only on the local computer. No cloud resources are needed.

  1. In Terminal A, create a new temporary directory. If it fails, stop and select another fresh directory before running the following commands.

    LAB_DIR=$(mktemp -d) || exit 1
    cd "$LAB_DIR" || exit 1
    printf '%s\n' 'Dairy networking lab: order 12' > index.html
    pwd

    Expect pwd to show your new temporary path. Write it down. That directory holds the single file the test server should serve.

  2. Leave Terminal A in the test directory. Start the service in that terminal.

    python3 -m http.server 8000 --bind 127.0.0.1

    Expect a serving message and an active process. If the port is already in use, choose another unused port such as 8001 for this exercise and use that same number for every comparison. Keep the binding on loopback. Python’s module here is suitable for this exercise and does not need to be used as a production web server.

  3. Open Terminal B on the same computer and ask for the known page. Then request a name you did not create.

    curl -i http://127.0.0.1:8000/
    curl -i http://127.0.0.1:8000/missing-lab-page.html

    Expect HTTP 200 and the line Dairy networking lab: order 12 from the first call. The second call should return HTTP 404. Both requests reached the same listening service. The paths were different. If you prefer a browser, open the same URLs and inspect the status in Developer Tools.

  4. Return to Terminal A and press Ctrl+C to stop the lab server. Run the original request again from Terminal B.

    curl --connect-timeout 3 -i http://127.0.0.1:8000/

    Expect a connection error if no other program is using that port. Compare it with the earlier 404: there is no HTTP response from this lab server when it is no longer listening. A connection error belongs to a different layer than an application response.

For cleanup, keep the server stopped. In the terminal that created the temporary directory, first print the path you recorded. If it is the exact directory you made for the exercise, leave it, remove its single test file and use rmdir to remove the empty directory. If the name or contents are different, inspect them instead of deleting anything else. You can also leave the temporary folder to your operating system’s cleanup. The lab did not open access to other devices.

Collect evidence from your lab EC2 instance

If you already have an authorized training instance and an approved SSH path, repeat the observation from both sides. This optional lab does not need a production site or a change to somebody else’s firewall. Use your own instance ID and address. If you are just reading the chapter, substitute the printed examples from the route sections into your notebook and perform the same decisions on paper.

  1. In the EC2 console, note the Region, instance ID, subnet, primary private IPv4 and public IPv4 association if present. Identify the security group attached to the instance’s network interface. A missing public IPv4 is expected in a private-instance design.
  2. Before connecting, run hostname locally. After using the approved SSH method, run it again on the instance. Verify the two outputs so you know where later commands run.
  3. On the instance, run ip -4 addr, ip route and ss -ltn. These show assigned IPv4 addresses, IPv4 routes, and TCP sockets in listening state. If an address appears only in the EC2 console, explain why a public IPv4 association can be external to the guest’s visible interface address.
  4. If your own test web service is installed, request its local endpoint with curl -i and record the result. Then request the intended outside path only if that access was part of your lab design. A local result and an outside result verify separate things.
  5. If you intentionally stop an EBS-backed lab instance per your plan, record the new public IPv4 after start and retest using that value. The instance keeps its identity, and saved files on retained EBS volumes can survive. Network association and service startup still need checking.

When a test fails, write the first concrete observation before changing anything. If the name does not resolve as expected, compare the DNS result. If the connection times out, confirm the current destination address, the correct subnet route and permissions for the intended port. If a listener is reached but SSH refuses the identity, check the instance’s AMI username and the authorized key rather than opening a wider route. If HTTP returns status 500, investigate the program that generated the error and the services it calls. A network rule cannot fix a failed database query.

Use the training environment’s cleanup plan to remove any test resources created for this exercise. Leave shared or production resources unchanged. For a disposable instance, stop or terminate it as intended by the lab, then inspect its attached volumes and allocated public addresses. Check other resources you may have created, such as a NAT gateway or load balancer, because they can remain allocated after an instance stops.

Explain the result before changing the design

A laptop can reach the public homepage, but its submission fails. Where do you start?

The homepage establishes that the browser could resolve and reach the front door for that request. See which URL and method the submission uses. Read its status, then check the application’s error and dependency logs if it received the request. A private database can fail even while the public page and its listener are healthy. Test the second and third arrows from the chapter’s drawing.

A browser opens 127.0.0.1 on an EC2 host but a second laptop cannot use that address to reach it. Explain the result.

Loopback points to the same host where the request runs. From EC2 it reaches the EC2 process, and from a laptop it stays on that laptop. Choose an approved reachable address to test across machines and confirm the service listens there. Keep internal services on loopback if a reverse proxy on the same machine serves as their intended entry point.

Two resources are in an AWS subnet with an internet gateway route. Can you assume every one of them accepts direct IPv4 traffic from the internet?

No. Check the resource’s public IPv4 association, whether it has a listening service and whether the intended protocols and sources are allowed. A public route supplies one part of the path. A private app target behind a public load balancer can receive requests from that load balancer while having no direct public IPv4 entry.

Why can an app reach a download service through NAT while an outside user cannot start a connection back to that app?

The app started a connection and the NAT gateway can translate and track its return path. That allows the reply in the established flow. An unsolicited outside request is not the reply to that flow. A public application needs a separately planned entry point and permission boundary.

Which parts of a network test would you record in a team’s incident notes?

Record the time, the test machine, destination hostname and returned address, network path, protocol and port, and the exact observed response or error. Note whether the destination was reached by IPv4 or IPv6. A coworker can repeat those details. “The website did not work” leaves out the information required to reproduce or explain the failure.

Check your understanding of one connection

  1. The office laptop is 192.168.40.18/24. Its printer is 192.168.40.30 on the same network. Which next hop normally applies for that printer? Choose the local interface, the default gateway, or the DNS server.

    Answer and reasoning

    The local interface. Both addresses fit the same directly connected range and the local network permits access. The default gateway is for a destination that needs a route outside that link.

  2. A student reaches a web server on TCP 443 from TCP 51030. Which destination port does the server’s reply use before any translating device rewrites it? Choose 22, 443, or 51030.

    Answer and reasoning

    51030. That was the client’s source port. The server uses its own service port as the reply source and sends back to the client’s selected port.

  3. A new AWS IPv4 lab subnet is 10.30.40.0/27. Does it have 27, 32, or 64 assignable addresses under the usual AWS subnet rules?

    Answer and reasoning

    27. The slash length leaves five bits, so the block holds 32 total addresses. AWS reserves five in the ordinary subnet example.

  4. Two browsers get different results from an updated hostname. An A record is correct and an AAAA record points to a path the service cannot use. Which layer-specific test gives useful evidence?

    Answer and reasoning

    Compare a real IPv4 request and IPv6 request separately from an authorized dual-stack host. One valid record does not verify the other path. Check the DNS answer, network rule and listener for the failing address family.

  5. You change the wording on an existing HTTP page, then test it and get 404. Which was established by that code: a DNS server replied, a web component answered, or the page content was saved correctly?

    Answer and reasoning

    A web component answered that request. Check the path and selected web service. The status itself does not prove which file was deployed. HTTPS connection details may also be different when testing with another host name.

Revision cards

Host name, address and route
DNS resolves the name. An IP address names a destination for the packet. The route selects the next hop for reaching it. In your notes, keep the name, returned address and routing table apart.
Port and socket
A server waits on a transport protocol, local address and port. Connections also have a client address and port. A path to the machine and the correct application listener are both needed.
CIDR number
The slash length describes the prefix bits. Subtract it from 32 for IPv4 to count the varying bits. Compute the total first, then apply the specific subnet’s reservations.
Private is a routing scope
A private IPv4 can be fixed or leased. Public and private describe where traffic can go. Static and dynamic describe the process that chose and retained the address.
NAT return mapping
Outgoing connections can share one outward address. Translation state helps their replies find the right inside connection. Plan public entry points separately from private outbound paths.
AWS reachability
Verify subnet routing, addresses, rules and the service listener. A missing DNS answer, a connection timeout and an HTTP error send you to different next checks.

Technical 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

Paris Fashion Hub is a fashion business in Paris. Camille Laurent looks after its IT and cloud work. They count money in EUR and run their AWS resources in the eu-west-3 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.

Paris Fashion Hub plans the VPC 10.145.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 your own private network in AWS. Everything else lives inside it.

Create a VPC with the CIDR block 10.6.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 Test a website from the server

curl shows whether the web server answers, even before DNS is ready.

Request http://localhost and show only the response headers.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium First usable IP for a server

The first 4 addresses are reserved by AWS.

What is the first IP address a server can get in 10.145.20.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 Find the VPC router address

AWS reserves base+1 for the router.

Which address does AWS reserve for the VPC router in subnet 10.145.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

AWS keeps 5 addresses in every subnet.

How many addresses can Paris Fashion Hub use for servers in subnet 10.145.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 Usable IPs in a /28

/28 is the smallest AWS subnet.

Subnet 10.145.9.0/28 on AWS. How many usable IPs?

  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 Create a subnet in one AZ

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

In vpc-01af0ffe22deadbee, create subnet 10.6.1.0/24 in eu-west-3a.

  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 Do these VPCs overlap?

Peering fails when ranges overlap.

Can VPC 10.145.0.0/16 peer with VPC 10.145.128.0/17? Answer yes or no.

  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 Range of a /26

Knowing the range stops subnets from overlapping.

Write the first and last address of 10.145.3.64/26 (like a.b.c.d - e.f.g.h).

  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 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.145.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.