DevOps.Academy
CoursesCurriculumInterview prepPricing
◔My learningSign in
DevOps.Academy

Free, hands-on DevOps lessons. Made with care in India.

System status

Learn

All coursesLinux roadmapCurriculumInterview questionsCheat sheetsMy learning

Academy

PricingCertificates

Legal

PrivacyTermsContact

devops.rajeev.pro

Networking for DevOps · revision

Networking cheat sheet

Recall first: read each stage's one-line summary and try to remember its commands. Then open the stage to check yourself.

12 stages36 commands

01How networks workEvery request passes through four TCP/IP layers: application, transport, internet and link. Each adds a header around the one above. Every machine decides where a packet goes next (route table) and which MAC that next hop has (ARP).
  • ip -br addr

    Show interfaces and their addresses, one line each

  • ip route

    Show where packets for each destination go next

  • ip neigh

    Show the ARP cache, IP to MAC for local neighbours

  • tcpdump -i eth0 -e -n -c 6 tcp port 80

    Capture six HTTP packets, with MAC addresses

Remember

  • L4 means TCP and ports; L7 means HTTP and other application protocols.
  • The destination IP is the far server; the destination MAC is only the next hop.
  • ifconfig, route and arp are deprecated; use ip.

Watch for A packet's destination MAC is usually your gateway's, not the server's. That's normal.

Open the lesson: How networks work: layers, packets and the next hop →
02IP addressing and subnetsA CIDR block's /number counts the fixed network bits; the rest number the hosts. Plan one /16 per network and /24 subnets inside it, never overlapping networks you may connect. 10/8, 172.16/12 and 192.168/16 are private and reach the internet through NAT.
  • ip -6 addr show eth0 | grep inet6

    Show the interface's IPv6 addresses

Remember

  • /24 is 256 addresses, /16 is 65,536; each extra bit halves the block.
  • AWS reserves five addresses in every subnet.
  • 169.254.169.254 is where cloud servers read their metadata.

Watch for 100.64.0.0/10 looks private but is carrier-grade NAT space, not an RFC 1918 range.

Open the lesson: IP addressing and subnets: reading CIDR →
03TCP, UDP and portsTCP opens with SYN, SYN-ACK, ACK, acknowledges every byte and closes with FIN. Refused (a fast RST) means the host is up and nothing listens; a timeout means the SYN was dropped on the way. UDP sends single datagrams with no reply.
  • nc -zv 10.50.0.10 8080

    Test whether a TCP port accepts connections

  • nc -zv -w 3 10.50.0.99 8080

    The same test with a 3-second timeout

  • ss -tlnu

    List listening TCP and UDP sockets with numeric ports

Remember

  • Refused points at the app; timed out points at the path or a firewall.
  • 0.0.0.0 listens on every interface; 127.0.0.1 accepts local connections only.
  • Cloud security groups drop packets, so a missing rule looks like a timeout.

Watch for A UDP port check can't tell open from filtered, because nothing answers either way.

Open the lesson: TCP, UDP and ports: refused is not timed out →
04DNSA recursive resolver walks root, TLD and authoritative servers, then caches each answer for its TTL. "Propagation" is caches expiring. Linux checks /etc/hosts, then the nameserver in /etc/resolv.conf.
  • dig @a.root-servers.net com NS +norecurse +noall +authority

    Ask a root server who runs .com

  • dig github.com MX +short

    Show where a domain's mail goes

  • dig @8.8.8.8 example.com A +noall +answer

    Ask a specific resolver; column 2 is cache time left

  • grep hosts /etc/nsswitch.conf

    See the order Linux resolves names in

Remember

  • NXDOMAIN means no such name; NOERROR with no answer means no record of that type.
  • Lower the TTL a day before a planned change.
  • dig skips /etc/hosts; getent hosts follows the same order as your apps.

Watch for A CNAME can't sit at the zone apex. Use your provider's ALIAS or flattening.

Open the lesson: DNS: how names become addresses →
05HTTPHTTP is a request line, headers, a blank line and an optional body. The status family says who to blame, and 502 or 504 come from the proxy. curl -w splits a slow request into DNS, connect, TLS, wait and download.
  • curl -v http://example.com -o /dev/null

    Show the request and response headers

  • curl -sIL http://github.com | grep -iE '^HTTP|^location'

    Follow redirects and show each hop

  • curl -s --http1.1 -o /dev/null -w 'http %{http_version}\n' https://github.com

    Force HTTP/1.1 and print the version used

Remember

  • 502: the proxy got a bad answer from your app. 504: your app never answered in time.
  • Time to first byte minus TLS time is the server's own work.
  • POST is not safe to retry; GET, PUT and DELETE should be.

Watch for A cached CDN response (Age, cf-cache-status HIT) never reached your server, so your app logs won't show it.

Open the lesson: HTTP: read a request like a log →
06TLS and HTTPSTLS gives encryption, integrity and authentication. A leaf certificate is valid only for the names in its SAN list and is trusted through intermediates up to a root in the trust store. Most outages are expired certificates or missing intermediates.
  • echo | openssl s_client -connect github.com:443 -servername github.com

    Show the certificate chain, TLS version and verify result

  • curl -sS https://expired.badssl.com -o /dev/null

    See what an expired certificate error looks like

Remember

  • Always pass -servername (SNI) to openssl s_client, or you may get the wrong certificate.
  • Serve the full chain: some clients don't fetch missing intermediates.
  • Alert on certificate expiry at 14 days left.

Watch for curl -k and verify=False hide the error by turning off authentication. Never ship them.

Open the lesson: TLS and HTTPS: certificates without the mystery →
07Routing and NATThe kernel picks the most specific matching route; the default route is the fallback. Source NAT rewrites the sender and tracks a mapping for replies. traceroute probes increasing TTLs; a silent hop does not prove a drop.
  • ip route

    List the kernel's routes

  • ip route get 1.1.1.1

    Show the selected next hop for one address

  • traceroute -n example.com

    Probe the route without reverse DNS lookups

  • mtr -n example.com

    Repeat route probes and summarize loss and delay

Remember

  • A more specific prefix can override the default route.
  • NAT is translation and state, not an allow policy.
  • A * in traceroute means no probe reply arrived in time.

Watch for The network rule inside a container does not show Docker's host-side NAT table.

Open the lesson: Routing and NAT: finding the next hop →
08FirewallsStateful filters track a flow and permit matching replies; stateless filters evaluate each packet separately. nftables hooks distinguish local input from forwarded traffic. AWS security groups are stateful, while NACLs are stateless and ordered.
  • nft list ruleset

    Inspect nftables tables, chains, rules and policies

  • nft list chain inet lesson input

    Inspect the disposable lab's input chain

  • iptables -S

    Show iptables-compatible filter rules

Remember

  • Check the default policy and management path before changing rules.
  • NACL reply traffic needs a matching rule in the opposite direction.
  • A permitted network connection still needs application authentication.

Watch for Never test a new default-drop policy on a remote server without recovery access.

Open the lesson: Firewalls: allow only the traffic you need →
09Proxies and load balancingA reverse proxy accepts a client connection and opens another connection to an upstream. L4 routes transport connections; L7 can inspect HTTP. A useful health check tests readiness, not just an open port.
  • nginx -t

    Validate Nginx configuration syntax before reload

  • nginx -T

    Print the loaded Nginx configuration for inspection

  • bash devops-academy-tools/networking-lab/09-capture.sh

    Run the temporary Nginx reverse-proxy lab

Remember

  • Client-to-proxy and proxy-to-upstream are separate connections.
  • Do not trust forwarded client-IP headers from arbitrary sources.
  • A TCP health check does not prove the app can serve a request.

Watch for Nginx's open-source upstream health checks are passive; Plus adds active checks.

Open the lesson: Proxies and load balancing: one front door →
10SSH and remote accessA user private key stays on the client; the public key is authorized on the server. The host key identifies the server. SSH config simplifies hosts, ProxyJump reaches private machines, and LocalForward exposes a local port.
  • ssh -N -L 15432:db.internal:5432 bastion

    Forward a local port through a bastion

  • bash devops-academy-tools/networking-lab/10-capture.sh

    Run the temporary key-authentication lab

Remember

  • Verify a server host-key fingerprint through a trusted channel.
  • Do not copy private keys to a bastion or server.
  • The database still needs its own authentication and TLS.

Watch for Agent forwarding gives the remote host access to request signatures from your local agent.

Open the lesson: SSH and remote access: reach servers safely →
11Container networkingA network namespace isolates interfaces and routes. A veth pair links it to a host bridge. Docker user-defined networks provide an explicit boundary and service aliases; Kubernetes CNI configures Pod connectivity.
  • docker network create app-net

    Create a named Docker network

  • docker network inspect app-net

    Inspect its containers, options and subnet

  • getent hosts api

    Resolve a network alias from a participating container

  • ip -br addr

    Inspect interfaces in the current network namespace

Remember

  • Containers in a Pod share one network namespace and Pod IP.
  • A Docker peer does not need a published port to reach a peer on its bridge.
  • A Kubernetes Service is separate from the CNI plugin.

Watch for Remove the temporary containers and network after a local exercise.

Open the lesson: Container networking: bridges, namespaces and Pods →
12Network troubleshootingCheck DNS, route, TCP, TLS/HTTP, and then application logs. Refused is an active rejection; timeout means no reply arrived in time. Compare packet captures at both ends to locate the boundary.
  • tcpdump -i eth0 -nn -c 4 'tcp port 80'

    Capture four numeric TCP packets on port 80

  • nc -zvw 2 server 8081

    Test a TCP port with a two-second timeout

  • bash devops-academy-tools/networking-lab/12-capture.sh

    Run the disposable troubleshooting scenarios

Remember

  • A refused connection commonly points to a listener or active reject.
  • A timeout may be a silent filter or unreachable route.
  • Capture narrowly; packet data may contain sensitive information.

Watch for One capture only shows traffic visible on that interface.

Open the lesson: Network troubleshooting: follow the packet →
← Back to the Networking course