Assignments
25 practical assignments: 10 ๐ข Beginner, 10 ๐ก Intermediate, 5 ๐ด Advanced. Each has an objective, tasks, acceptance criteria, collapsible hints and a bonus.
๐ข Beginner
A1. Know your host's network ๐ข
Objective: Read a Linux host's network configuration without a GUI.
Tasks:
- List interfaces and addresses, and identify the primary IP and its prefix length.
- Print the routing table and name the default gateway.
- Find the DNS resolver your host uses.
- Find the MAC address of the default gateway.
Expected outcome: A short text file listing IP/prefix, gateway, resolver and gateway MAC, with the command that produced each.
Hints
ip -br addr, ip route, resolvectl status or cat /etc/resolv.conf, ip neigh show. Ping the gateway first so it appears in the neighbor table.
Bonus: Explain why 127.0.0.53 appears in /etc/resolv.conf on Ubuntu.
A2. Subnet math ๐ข
Objective: Do CIDR calculations by hand and verify with a tool.
Tasks:
- For
10.20.30.0/24,10.20.30.64/26and172.16.0.0/20write the network, broadcast, first and last host, and host count. - Split
10.0.0.0/16into four equal subnets and list them. - Decide whether
10.0.5.9is inside10.0.4.0/22.
Expected outcome: All answers correct, checked with ipcalc or Python's ipaddress module.
Hints
Hosts = 2^(32 - prefix) - 2 (AWS subtracts 5). python3 -c "import ipaddress as i; print(list(i.ip_network('10.0.0.0/16').subnets(prefixlen_diff=2)))".
Bonus: How many usable IPs does an AWS /28 subnet give you, and why is that too small for an EKS node group?
A3. Read a DNS answer ๐ข
Objective: Query DNS and interpret each section of the output.
Tasks:
- Run
dig example.comand label the question, answer, authority and additional sections. - Fetch
A,AAAA,MX,NSandTXTrecords for a domain you own or a public one. - Query the same name against
@1.1.1.1and@8.8.8.8and compare TTLs. - Run it twice against your local resolver and watch the TTL count down.
Expected outcome: A table of record types with values and TTLs, plus a sentence explaining why the TTL decreased on the second query.
Hints
dig +short, dig +noall +answer, dig NS example.com. A counting-down TTL means you were served from the resolver's cache.
Bonus: Use dig -x for a reverse lookup of an IP and explain what a PTR record is for.
A4. See the phases of an HTTP request ๐ข
Objective: Use curl to separate DNS, connect, TLS and server time.
Tasks:
- Run
curl -v https://example.com -o /dev/nulland mark where DNS, TCP connect, TLS and the HTTP request/response happen. - Use
-wwithtime_namelookup,time_connect,time_appconnect,time_starttransferandtime_total. - Compare HTTP/1.1 (
--http1.1) with HTTP/2 (--http2).
Expected outcome: A timing breakdown for three sites and a note on which phase dominates each.
Hints
curl -s -o /dev/null -w 'dns=%{time_namelookup} tcp=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://example.com
Bonus: Write a shell function curltime URL that prints this line.
A5. Listening ports and who owns them ๐ข
Objective: Map sockets to processes.
Tasks:
- Start
python3 -m http.server 9000in the background. - Find it with
ss -ltnpand withlsof -i :9000. - Bind a second server to the same port and capture the exact error.
- Restart the first on
127.0.0.1only, and test it from another machine or with the host's non-loopback IP.
Expected outcome: You can explain 0.0.0.0 vs 127.0.0.1 vs :: and show that a loopback-only service is unreachable remotely.
Hints
The error is OSError: [Errno 98] Address already in use. python3 -m http.server 9000 --bind 127.0.0.1.
Bonus: Use ss -s to count sockets by state and name three TCP states you see.
A6. Test connectivity layer by layer ๐ข
Objective: Distinguish "can't resolve", "can't route", "closed" and "filtered".
Tasks:
pinga host, thenpinga name that does not exist and record both failures.- Use
nc -vz host portagainst an open port, a closed port on a reachable host, and a port dropped by a firewall (useiptables -A INPUT -p tcp --dport 9001 -j DROPon a lab VM). - Record the exact output and the time taken for each.
Expected outcome: A table mapping each failure to its message (Name or service not known, Connection refused, timed out) and what it means.
Hints
Refused is instant (RST). Timeout means a silent drop. Use -w 3 to cap the wait. Remove your iptables rule afterwards with -D.
Bonus: Show the difference with REJECT instead of DROP.
A7. Trace a path ๐ข
Objective: Use traceroute and mtr to see hops and latency.
Tasks:
- Run
traceroute -nandmtr -rwn -c 20to a public host. - Explain the
* * *lines and why they may not mean a problem. - Compare the path to two destinations in different regions.
Expected outcome: A report with hop count, where latency jumps, and the explanation of ICMP rate limiting on intermediate routers.
Hints
Loss at a middle hop that does not continue to the final hop is usually rate limiting, not real loss. Loss that persists to the end is real.
Bonus: Run traceroute -T -p 443 and explain why TCP probes sometimes succeed where ICMP fails.
A8. Edit /etc/hosts and understand resolution order ๐ข
Objective: See how a name is resolved on Linux.
Tasks:
- Read
/etc/nsswitch.confand find thehosts:line. - Add
127.0.0.1 shop.localto/etc/hostsand test it withgetent hosts shop.local,pingandcurl. - Show that
dig shop.localdoes not see it.
Expected outcome: You can explain why getent and curl use /etc/hosts but dig does not.
Hints
dig talks straight to a DNS server. Applications call the libc resolver, which follows nsswitch.conf (files, then DNS).
Bonus: Run a local server on port 8000 and reach it as http://shop.local:8000.
A9. Serve a page with nginx ๐ข
Objective: Install nginx and serve a static site.
Tasks:
- Install nginx, create
/var/www/demo/index.htmland a server block listening on port 8081. - Validate with
nginx -t, reload, and test with curl. - Read
access.loganderror.logand find your request. - Request a missing file and note the status and the log line.
Expected outcome: curl -i localhost:8081 returns 200 with your page and curl -i localhost:8081/nope returns 404, both visible in the logs.
Hints
root /var/www/demo; inside server { listen 8081; }. Config goes in /etc/nginx/conf.d/demo.conf. Reload with systemctl reload nginx.
Bonus: Add add_header X-Served-By demo always; and confirm it with curl -I.
A10. Draw and explain a public/private subnet design ๐ข
Objective: Be able to explain a basic VPC on a whiteboard.
Tasks:
- Draw a VPC with one public and one private subnet, IGW, NAT gateway, route tables and the two security groups.
- Write each route table's rows.
- Answer: what makes a subnet public? Where must the NAT gateway live? Why can the app not be reached from the internet?
Expected outcome: A clear diagram (Mermaid or image) and three correct written answers.
Hints
A route to an IGW makes a subnet public. The NAT gateway sits in a public subnet because it needs the IGW. Private instances have no public IP and no inbound route.
Bonus: Add a second AZ and explain how many NAT gateways you would run and why.
๐ก Intermediate
A11. Build the VPC with Terraform ๐ก
Objective: Codify the lab network.
Tasks:
- Write Terraform for a VPC, two public and two private subnets across two AZs, an IGW, a NAT gateway per AZ and route tables.
- Use variables for CIDR and AZ count, and outputs for subnet IDs.
- Run
plan,apply, thendestroy.
Expected outcome: terraform apply yields a working network; instances in private subnets reach the internet through their own AZ's NAT.
Hints
Use cidrsubnet(var.vpc_cidr, 8, count.index). Each private route table points to the NAT in the same AZ. aws_eip with domain = "vpc".
Bonus: Replace the per-AZ NATs with a single NAT behind a variable toggle for dev, and document the failure trade-off.
A12. nginx reverse proxy with security headers and rate limiting ๐ก
Objective: Harden a proxy.
Tasks:
- Proxy
/api/to a backend on127.0.0.1:8080and/to static files. - Add
limit_req_zoneat 5 requests per second per client IP with a burst of 10. - Add
Strict-Transport-Security,X-Content-Type-OptionsandX-Frame-Optionsheaders. - Prove rate limiting with a loop of requests and count the
503responses (or setlimit_req_status 429).
Expected outcome: Normal requests pass; a burst of 50 requests shows rejections, and headers appear on every response.
Hints
limit_req_zone $binary_remote_addr zone=api:10m rate=5r/s; in http {}, then limit_req zone=api burst=10 nodelay; in the location. Test: for i in $(seq 50); do curl -s -o /dev/null -w '%{http_code}\n' localhost/api/; done | sort | uniq -c.
Bonus: Behind a load balancer, make nginx rate limit on the real client IP using real_ip_header X-Forwarded-For and set_real_ip_from.
A13. TLS with Let's Encrypt and auto-renewal ๐ก
Objective: Issue and renew a trusted certificate.
Tasks:
- Point a real DNS name at a server and issue a certificate with certbot (
--nginxor--webroot). - Confirm the chain with
openssl s_clientand the expiry withopenssl x509 -noout -dates. - Test renewal with
certbot renew --dry-runand find the renewal timer. - Add a deploy hook that reloads nginx.
Expected outcome: Browser shows a valid certificate; dry-run renewal succeeds; the timer is active.
Hints
systemctl list-timers | grep certbot. Hooks live in /etc/letsencrypt/renewal-hooks/deploy/. Rate limits apply, so use --staging while experimenting.
Bonus: Get a wildcard certificate using the DNS-01 challenge with the Route 53 plugin.
A14. Capture and read a TCP session ๐ก
Objective: Use tcpdump to explain a connection from SYN to FIN.
Tasks:
- Capture
curl http://localhost:8081/on the loopback withtcpdump -nn -i lo port 8081. - Identify the handshake, the request, the response, and the teardown flags.
- Write the capture to a pcap and open it with
tshark -ror Wireshark. - Find the TCP window size and MSS in the SYN.
Expected outcome: An annotated capture listing each packet with its meaning.
Hints
-nn avoids DNS and port name lookups; -A shows ASCII payload; -S shows absolute sequence numbers. MSS appears as mss 65495 on loopback.
Bonus: Capture a refused connection and show the RST packet; capture a firewalled one and show repeated SYN retransmits.
A15. DNS records and failover in Route 53 ๐ก
Objective: Operate DNS beyond a single A record.
Tasks:
- Create two servers (or two IPs) and a health check against each.
- Create a failover record pair (primary and secondary) with a 60 second TTL.
- Stop the primary and measure how long until
digreturns the secondary. - Create a weighted pair 90/10 and verify the distribution by sampling 100 queries.
Expected outcome: Failover completes within roughly health-check interval times threshold plus TTL; weighted answers are close to 90/10.
Hints
Health check: HTTP, interval 10 s, failure threshold 3. Add a polling loop: while true; do date +%T; dig +short app.example.com; sleep 5; done. Resolver caching extends perceived failover.
Bonus: Add a private hosted zone attached to your VPC that overrides the same name with an internal IP (split-horizon DNS).
A16. Security groups vs NACLs experiment ๐ก
Objective: Prove statefulness by experiment.
Tasks:
- In the lab VPC, allow inbound 8080 on a security group only and confirm it works.
- Add a custom NACL on the subnet allowing inbound 8080 but denying all outbound, and observe the failure.
- Fix it by allowing outbound ephemeral ports
1024-65535. - Add an explicit NACL deny for your own IP and show that the security group alone cannot do that.
Expected outcome: A written explanation, backed by results, of why NACLs need return-traffic rules and security groups do not.
Hints
Security groups are stateful (return traffic allowed automatically). NACLs are stateless and evaluated by rule number, lowest first. Remember the default * deny rule.
Bonus: Turn on VPC Flow Logs and find the REJECT records for your blocked packets.
A17. Load balance two backends with health checks ๐ก
Objective: Run an upstream pool and observe failover.
Tasks:
- Start two backends that return their hostname.
- Configure an nginx
upstreamwith both,max_fails=2 fail_timeout=10s. - Run
curl20 times and confirm round robin; then stop one backend and confirm no errors reach the client. - Switch to
least_connandip_hashand describe when each fits.
Expected outcome: Zero client-visible errors after the first failed attempt, with proxy_next_upstream retrying on the other node.
Hints
proxy_next_upstream error timeout http_502; only retries idempotent requests by default. Watch /var/log/nginx/error.log for upstream messages.
Bonus: Replace nginx with HAProxy using option httpchk GET /healthz for true active checks.
A18. Debug an intentionally broken stack ๐ก
Objective: Apply the layered workflow to unknown faults.
Tasks:
- Have a teammate (or a script) break five things in your lab: a DNS record, a security group rule, an nginx
proxy_passport, the certificate's SAN and a stopped service. - Without being told which, find each in under five minutes, using only
dig,curl -v,ss,tcpdumpandopenssl. - For each, write symptom, command, cause, fix.
Expected outcome: Five documented diagnoses, each ordered resolve, connect, handshake, request.
Hints
Start at DNS and move up. Timeout points to firewall or routing; refused points to a stopped listener; TLS errors point to certificate or SNI; 502 points to the upstream.
Bonus: Write a netcheck.sh that runs all these checks for a hostname and prints a pass or fail line per layer.
A19. Docker and container networking ๐ก
Objective: Understand bridge networks, port publishing and DNS between containers.
Tasks:
- Run two containers on the default bridge and on a user-defined bridge; show that name resolution works only on the user-defined one.
- Publish a port with
-p 8080:80and find the iptables DNAT rule that implements it. - Inspect the network with
docker network inspectand find the container IPs. - Run a container with
--network hostand explain the trade-off.
Expected outcome: A short write-up with the commands and the iptables output for the DNAT rule.
Hints
sudo iptables -t nat -L DOCKER -n shows DNAT rules; ip link shows the docker0 and br-* bridges and veth pairs. User-defined networks have an embedded DNS at 127.0.0.11.
Bonus: Create a network with --internal and prove containers on it cannot reach the internet.
A20. Kubernetes Service and DNS walkthrough ๐ก
Objective: Trace how a pod reaches another pod by name.
Tasks:
- On a local cluster (kind or minikube) deploy two replicas of nginx behind a ClusterIP Service.
- From a debug pod run
nslookup web.default.svc.cluster.localandcurl http://web. - Read
/etc/resolv.confin the pod and explainsearchandndots:5. - Find the Service's endpoints and the kube-proxy rules that load balance to them.
Expected outcome: You can explain every step from name to pod IP, with kubectl get endpointslices and the iptables or IPVS output as evidence.
Hints
kubectl run dbg --rm -it --image=nicolaka/netshoot -- bash. On the node: iptables-save | grep web. CoreDNS config is the coredns ConfigMap in kube-system.
Bonus: Apply a default-deny NetworkPolicy and then allow only the frontend pods to reach the backend.
๐ด Advanced
A21. Multi-VPC connectivity design and build ๐ด
Objective: Connect networks without overlap and without transitive surprises.
Tasks:
- Create two VPCs with non-overlapping CIDRs and peer them; add routes on both sides and security group rules referencing the peer CIDR.
- Add a third VPC peered only to the second and prove that VPC 1 cannot reach VPC 3.
- Replace the three peerings with a Transit Gateway and re-test.
- Write a one-page comparison of peering, Transit Gateway and PrivateLink covering transitivity, cost, scale and use cases.
Expected outcome: Working reachability matrix before and after, and a comparison that justifies when you would choose each.
Hints
VPC peering is non-transitive. Both route tables need routes to the peer CIDR. Transit Gateway needs attachments, route table associations and propagations. Use aws ec2 describe-route-tables to check for missing routes.
Bonus: Expose a service from VPC 2 to VPC 1 using an NLB and PrivateLink, with no routes between the VPCs.
A22. Diagnose and fix MTU and conntrack problems ๐ด
Objective: Reproduce two subtle, production-grade network faults.
Tasks:
- Lower the MTU of one interface on a lab VM (
ip link set dev eth0 mtu 1200) behind a path that blocks ICMP, and show that small requests work while large downloads hang. Prove it withping -M do -s 1400 host. - Fix it with correct MTU or MSS clamping (
iptables -t mangle ... --clamp-mss-to-pmtu), and re-test. - On another VM set
net.netfilter.nf_conntrack_maxvery low, generate load withaborwrk, and capture thenf_conntrack: table full, dropping packetmessage. - Raise the limit sensibly and show the current usage with
conntrack -C.
Expected outcome: Both faults reproduced, diagnosed with the right command and fixed, with a note on how you would alert on each in production.
Hints
tracepath host reveals the path MTU. The symptom of PMTUD failure: handshake works, big responses stall. Watch dmesg -w and /proc/sys/net/netfilter/nf_conntrack_count. Do not leave the low limit in place.
Bonus: Show ephemeral port exhaustion by making many connections to a single destination from one source IP and tuning net.ipv4.ip_local_port_range.
A23. Build a NAT gateway and router by hand on Linux ๐ด
Objective: Understand what a NAT gateway does by building one.
Tasks:
- Use three VMs (or network namespaces): client (private), router (two interfaces), server (public).
- Enable forwarding with
sysctl net.ipv4.ip_forward=1and addiptables -t nat -A POSTROUTING -o <public-if> -j MASQUERADE. - Prove the server sees the router's address and not the client's, and inspect the translation with
conntrack -L. - Add DNAT port forwarding from the router's port 8080 to a service on the client.
- Disable forwarding and show exactly how the failure looks in
tcpdump.
Expected outcome: Working SNAT and DNAT, with captures proving addresses change at the router.
Hints
With namespaces: ip netns add, ip link add veth0 type veth peer name veth1, ip link set veth1 netns client. Remember the default route in the client namespace and rp_filter settings if replies disappear.
Bonus: Rewrite the rules with nft and compare readability.
A24. Zero-downtime TLS and certificate lifecycle ๐ด
Objective: Run certificates like production, with automation, monitoring and mTLS.
Tasks:
- Create a private CA with
openssl(orstep-ca), issue a server certificate with SAN and a client certificate. - Configure nginx for mutual TLS:
ssl_client_certificate,ssl_verify_client on. - Show a request with the client certificate succeeding and without it failing (
400 No required SSL certificate was sent). - Write a script or Prometheus blackbox probe that alerts when any certificate has less than 14 days left.
- Rotate the server certificate with
nginx -s reloadwhile a load generator runs, and prove zero failed requests.
Expected outcome: mTLS working, alert rule written, and a reload under load showing 0 errors.
Hints
curl --cert client.crt --key client.key --cacert ca.crt https://host. Expiry check: openssl x509 -checkend 1209600 -noout. blackbox_exporter exposes probe_ssl_earliest_cert_expiry. Reload is graceful; restart is not.
Bonus: Use cert-manager with a self-signed ClusterIssuer in Kubernetes and watch automatic renewal by shortening duration and renewBefore.
A25. Network design review: three-tier production architecture ๐ด
Objective: Produce a design you can defend in a system design interview.
Tasks:
- Design a three-tier app (web, app, database) across three AZs: CIDR plan with room to grow, subnet tiers, route tables, NAT strategy, security group chain, NACL stance.
- Add an ALB with ACM certificate and WAF, private connectivity to AWS services with VPC endpoints, and a VPN or Direct Connect path for on-prem.
- Add observability: VPC Flow Logs, ALB access logs, DNS query logs, and the alerts you would set.
- Estimate monthly NAT and cross-AZ data transfer cost for 5 TB outbound and explain how endpoints reduce it.
- List five failure modes (AZ loss, NAT failure, DNS outage, expired certificate, route table mistake) with detection and mitigation for each.
Expected outcome: A Mermaid diagram plus a two-page write-up with the numbers and trade-offs, reviewed by a peer.
Hints
Use a /16 per VPC with /20 subnets so tiers can scale. Reference security groups, not CIDRs. NAT cost is the hourly charge per gateway plus a per-GB processing fee, so S3 and DynamoDB gateway endpoints (free) cut the biggest share. Check current pricing on the AWS pricing page.
Bonus: Describe how the design changes for multi-region active-passive, including DNS failover and data replication.